:root {
  color-scheme: light;
  --bg: #eef5ff;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: #ffffff;
  --ink: #132034;
  --muted: #718096;
  --line: rgba(60, 94, 137, 0.14);
  --blue: #2479ff;
  --blue-2: #6db5ff;
  --green: #20b874;
  --amber: #f4a019;
  --red: #ef4f5f;
  --violet: #6f63ff;
  --shadow: 0 18px 48px rgba(42, 77, 126, 0.14);
  --shadow-soft: 0 10px 30px rgba(42, 77, 126, 0.1);
  font-family: "Manrope", "Avenir Next", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% -8%, rgba(36, 121, 255, 0.24), transparent 20rem),
    radial-gradient(circle at 92% 4%, rgba(32, 184, 116, 0.2), transparent 18rem),
    radial-gradient(circle at 70% 105%, rgba(111, 99, 255, 0.14), transparent 18rem),
    linear-gradient(180deg, #fbfdff 0%, #eef5ff 48%, #eaf2ff 100%);
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

.app-shell {
  position: relative;
  width: min(100%, 540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px calc(98px + env(safe-area-inset-bottom));
}

.view {
  display: none;
  animation: view-in 0.24s ease both;
}

.active-view {
  display: block;
}

.chat-view.active-view {
  display: flex;
  min-height: calc(100svh - env(safe-area-inset-top));
  flex-direction: column;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.topbar,
.brand-lockup,
.panel-head,
.hero-card,
.hero-actions,
.node-main,
.node-foot,
.data-row,
.chat-head,
.chat-preview,
.agent-card,
.agent-mini,
.period-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-lockup {
  min-width: 0;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 15px;
  color: #082616;
  background: linear-gradient(135deg, #a9ff54, #58e59b);
  box-shadow: 0 12px 24px rgba(41, 178, 109, 0.2);
  font-size: 24px;
  font-weight: 1000;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 9vw, 48px);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 0.95;
  letter-spacing: -0.065em;
}

h3 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.055em;
}

h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

.icon-button {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
  font-size: 24px;
  font-weight: 1000;
  cursor: pointer;
}

.icon-button.back {
  font-size: 36px;
  line-height: 1;
}

.icon-button.spinning {
  animation: spin 0.7s linear infinite;
}

.hero-card,
.panel-card,
.metric-card,
.agent-card,
.chat-preview,
.access-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-card {
  position: relative;
  min-height: 230px;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  padding: 22px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(226, 240, 255, 0.86)),
    var(--card);
}

.hero-copy {
  position: relative;
  z-index: 2;
  min-width: 0;
}

.hero-copy p {
  max-width: 300px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.42;
}

.hero-avatar {
  position: relative;
  z-index: 2;
  width: 116px;
  height: 116px;
  flex: 0 0 116px;
  border: 5px solid rgba(255, 255, 255, 0.92);
  border-radius: 34px;
  object-fit: cover;
  box-shadow: 0 20px 44px rgba(36, 121, 255, 0.18);
}

.status-pill,
.soft-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 1000;
  white-space: nowrap;
}

.status-pill {
  min-height: 34px;
  margin-bottom: 22px;
  padding: 8px 13px;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
}

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

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

.status-pill.fail {
  background: var(--red);
}

.primary-button,
.ghost-button,
.chip-button,
.send-button {
  border: 0;
  cursor: pointer;
  font-weight: 1000;
}

.primary-button {
  min-height: 46px;
  border-radius: 17px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  box-shadow: 0 14px 30px rgba(36, 121, 255, 0.24);
}

.primary-button.full {
  width: 100%;
  margin-top: 16px;
}

.ghost-button,
.chip-button {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 13px;
  color: var(--blue);
  background: rgba(36, 121, 255, 0.1);
}

.hero-actions {
  gap: 8px;
  flex-wrap: wrap;
}

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

.metric-grid.two {
  margin-bottom: 14px;
}

.metric-card {
  min-height: 118px;
  padding: 16px;
  border-radius: 25px;
  overflow: hidden;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.metric-card strong {
  display: block;
  margin: 12px 0 7px;
  font-size: 30px;
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.metric-card.blue {
  color: #fff;
  background: linear-gradient(135deg, #2479ff, #67b3ff);
}

.metric-card.green {
  background: linear-gradient(135deg, #dffbea, #ffffff);
}

.metric-card.amber {
  background: linear-gradient(135deg, #fff1d4, #ffffff);
}

.metric-card.red {
  background: linear-gradient(135deg, #ffe5eb, #ffffff);
}

.metric-card.blue span,
.metric-card.blue small {
  color: rgba(255, 255, 255, 0.82);
}

.panel-card {
  margin-top: 14px;
  padding: 18px;
  border-radius: 30px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.soft-badge {
  min-height: 32px;
  padding: 7px 11px;
  color: #185fc8;
  background: rgba(36, 121, 255, 0.1);
  font-size: 12px;
}

.bar-chart {
  display: flex;
  height: 174px;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 2px 0;
}

.bar-chart.tall {
  height: 220px;
}

.mini-bars .bar-chart {
  height: 148px;
}

.bar-item {
  display: grid;
  min-width: 38px;
  height: 100%;
  flex: 1 0 38px;
  grid-template-rows: 24px 1fr 18px;
  align-items: end;
  text-align: center;
}

.bar-value {
  align-self: start;
  color: var(--ink);
  font-size: 10px;
  font-weight: 950;
}

.bar-item i {
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 14px 14px 6px 6px;
  background: linear-gradient(180deg, #72bcff, #2479ff);
  box-shadow: 0 8px 20px rgba(36, 121, 255, 0.18);
  animation: bar-in 0.45s ease both;
}

.bar-item small {
  align-self: end;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.period-row {
  gap: 8px;
  overflow-x: auto;
  margin: 14px 0;
  padding-bottom: 2px;
}

.period-row button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 950;
}

.period-row button.active {
  color: #fff;
  background: var(--blue);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(36, 121, 255, 0.2);
}

.page-head {
  margin-bottom: 16px;
}

.page-head p:not(.eyebrow) {
  max-width: 430px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.node-stack,
.data-list,
.chat-list,
.agents-grid {
  display: grid;
  gap: 10px;
}

.node-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: rgba(255, 255, 255, 0.72);
}

.node-main {
  gap: 11px;
}

.node-flag {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 15px;
  background: #f0f6ff;
  font-size: 21px;
}

.node-main b,
.data-row b,
.agent-card b,
.chat-preview b {
  display: block;
  font-size: 16px;
  line-height: 1.08;
}

.node-main span,
.node-main small,
.data-row span,
.chat-preview span,
.agent-card span,
.agent-card p,
.muted {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.node-main span {
  margin-top: 5px;
}

.node-main small {
  margin-top: 3px;
}

.node-meta {
  margin-top: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.node-meta strong {
  font-size: 22px;
  letter-spacing: -0.05em;
}

.node-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.load-line {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 121, 255, 0.1);
}

.load-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #74d8ff, var(--blue));
  animation: load-in 0.55s ease both;
}

.load-line.danger i {
  background: linear-gradient(90deg, #ff8a9a, var(--red));
}

.node-foot {
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.data-row {
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.72);
}

.data-row > div {
  min-width: 0;
}

.data-row strong {
  flex: 0 0 auto;
  max-width: 42%;
  overflow-wrap: anywhere;
  text-align: right;
  font-size: 16px;
}

.data-row a {
  color: var(--blue);
}

.data-list.slim {
  gap: 8px;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

.agent-mini {
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  border: 0;
  border-radius: 22px;
  padding: 10px 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
  text-align: center;
  cursor: pointer;
}

.agent-mini b {
  font-size: 13px;
}

.agent-mini span {
  width: 100%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-photo {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(36, 121, 255, 0.16);
}

.agent-photo.big {
  width: 72px;
  height: 72px;
  flex-basis: 72px;
  border-radius: 24px;
}

.agent-card,
.chat-preview {
  width: 100%;
  gap: 13px;
  padding: 14px;
  border-radius: 25px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.agent-card {
  position: relative;
  border: 1px solid var(--line);
}

.agent-card::before {
  content: "";
  width: 5px;
  align-self: stretch;
  border-radius: 999px;
  background: var(--accent, var(--blue));
}

.agent-card > div {
  min-width: 0;
  flex: 1;
}

.agent-card p {
  margin: 7px 0 0;
}

.agent-card i {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 10px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 1000;
}

.chat-preview {
  border: 1px solid var(--line);
}

.chat-preview > div {
  min-width: 0;
  flex: 1;
}

.chat-preview span {
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-preview small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 900;
}

.chat-head {
  position: sticky;
  top: 0;
  z-index: 5;
  gap: 11px;
  margin: -4px -14px 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 251, 255, 0.9);
  backdrop-filter: blur(20px);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  object-fit: cover;
  box-shadow: var(--shadow-soft);
}

.chat-head h2 {
  overflow: hidden;
  margin: 0;
  font-size: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head p {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head > div {
  min-width: 0;
  flex: 1;
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 6px 0 96px;
  overflow: visible;
}

.message {
  max-width: min(88%, 420px);
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 13px 14px;
  border-radius: 21px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.42;
}

.message.agent {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
}

.chat-form {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 9;
  display: flex;
  width: min(calc(100% - 22px), 516px);
  transform: translateX(-50%);
  gap: 8px;
  align-items: flex-end;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.chat-form textarea {
  min-height: 44px;
  max-height: 130px;
  min-width: 0;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  padding: 12px 10px;
  color: var(--ink);
  background: transparent;
}

.send-button {
  min-height: 44px;
  border-radius: 18px;
  padding: 0 13px;
  color: #fff;
  background: var(--blue);
}

.send-button:disabled {
  opacity: 0.55;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(calc(100% - 22px), 516px);
  padding: 7px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

body.chat-open .tabbar {
  display: none;
}

body.chat-open .app-shell {
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.tab-button {
  min-height: 48px;
  border: 0;
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 1000;
  cursor: pointer;
}

.tab-button.active-tab {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(36, 121, 255, 0.24);
}

.empty-state {
  display: grid;
  min-height: 86px;
  place-items: center;
  border: 1px dashed rgba(60, 94, 137, 0.2);
  border-radius: 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
  font-weight: 900;
}

.empty-state.good {
  color: #0c8552;
  background: rgba(32, 184, 116, 0.1);
}

.access-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.access-card {
  width: min(100%, 430px);
  padding: 28px;
  border-radius: 30px;
}

.access-card h1 {
  margin: 18px 0 12px;
}

.access-card p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 30px;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 16px calc(50% - 292px);
    border: 1px solid rgba(60, 94, 137, 0.11);
    border-radius: 42px;
    pointer-events: none;
  }

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

@media (max-width: 430px) {
  .hero-card {
    min-height: 248px;
    align-items: flex-start;
  }

  .hero-avatar {
    width: 96px;
    height: 96px;
    flex-basis: 96px;
    border-radius: 28px;
  }

  .metric-card strong {
    font-size: 26px;
  }

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

  .chat-form {
    width: min(calc(100% - 16px), 516px);
    border-radius: 22px;
  }

  .message {
    max-width: 92%;
  }
}

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

  .tab-button {
    font-size: 11px;
  }

  .send-button {
    padding: 0 10px;
    font-size: 12px;
  }
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bar-in {
  from {
    transform: scaleY(0.25);
    transform-origin: bottom;
  }
  to {
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

@keyframes load-in {
  from {
    width: 4%;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
