:root {
  color-scheme: dark;
  --bg: #050b0f;
  --panel: rgba(9, 19, 25, 0.88);
  --panel-strong: #0a151c;
  --line: #203944;
  --line-soft: rgba(77, 124, 139, 0.22);
  --text: #f2f7f7;
  --muted: #8aa0a9;
  --cyan: #5de3ef;
  --cyan-soft: rgba(93, 227, 239, 0.14);
  --mint: #58e3a0;
  --amber: #f0ba45;
  --red: #ff6f71;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 15% -10%, rgba(46, 154, 165, 0.13), transparent 35rem),
    radial-gradient(circle at 95% 20%, rgba(25, 94, 104, 0.1), transparent 32rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(79, 148, 160, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 148, 160, 0.045) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
}

.shell {
  position: relative;
  width: min(1500px, calc(100% - 44px));
  margin: 0 auto;
  padding: 38px 0 30px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow,
.section-kicker,
.meta-label,
.process-label,
.updated,
.host-uptime,
.footer {
  font-family: var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--cyan);
  font-size: 0.77rem;
}

.eyebrow span {
  margin: 0 8px;
  color: var(--muted);
}

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

.topbar h1 {
  margin-bottom: 0;
  font-family: var(--mono);
  font-size: clamp(1.8rem, 3vw, 3rem);
  font-weight: 560;
  letter-spacing: -0.05em;
}

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

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(88, 227, 160, 0.38);
  border-radius: 6px;
  color: var(--mint);
  background: rgba(39, 150, 100, 0.08);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.connection-pill.is-warning {
  border-color: rgba(240, 186, 69, 0.42);
  color: var(--amber);
  background: rgba(240, 186, 69, 0.08);
}

.connection-pill.is-warning .status-dot {
  background: var(--amber);
  box-shadow: 0 0 14px rgba(240, 186, 69, 0.45);
}

.status-dot,
.activity-dot,
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--mint);
  box-shadow: 0 0 14px rgba(88, 227, 160, 0.5);
}

.updated,
.host-uptime,
.meta-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.65rem;
}

.quiet-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.quiet-button:hover {
  border-color: #416373;
  color: var(--text);
}

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

.bot-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(130deg, rgba(20, 42, 51, 0.16), transparent 45%),
    var(--panel);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}

.bot-card {
  overflow: hidden;
}

.bot-card::before {
  display: block;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, var(--cyan), transparent 52%);
}

.bot-card.accent-amber::before {
  background: linear-gradient(90deg, var(--amber), transparent 52%);
}

.bot-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.bot-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bot-avatar-frame {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  padding: 2px;
  border: 1px solid rgba(93, 227, 239, 0.58);
  border-radius: 13px;
  background: var(--cyan-soft);
  box-shadow: 0 0 0 3px rgba(93, 227, 239, 0.05);
}

.accent-amber .bot-avatar-frame {
  border-color: rgba(240, 186, 69, 0.62);
  background: rgba(240, 186, 69, 0.1);
  box-shadow: 0 0 0 3px rgba(240, 186, 69, 0.05);
}

.bot-avatar-frame.is-offline {
  filter: grayscale(0.5);
  opacity: 0.72;
}

.bot-avatar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  object-fit: cover;
}

.bot-card h2 {
  margin: 2px 0 8px;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 580;
}

.bot-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
}

.bot-state.healthy {
  color: var(--mint);
}

.bot-state.unhealthy {
  color: var(--red);
}

.bot-state.unhealthy .status-dot {
  background: var(--red);
  box-shadow: 0 0 14px rgba(255, 111, 113, 0.45);
}

.process-label {
  margin: 4px 0 0;
  color: #627985;
  font-size: 0.62rem;
}

.bot-card-body {
  display: grid;
  grid-template-columns: 0.82fr 1.65fr;
  gap: 20px;
  padding: 18px 22px 22px;
}

.integrations {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
}

.integration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
}

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

.integration-state {
  color: var(--mint);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.state-checking,
.state-needs_auth {
  color: var(--amber);
}

.state-not_configured {
  color: #748791;
}

.state-offline {
  color: var(--red);
}

.bot-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.bot-metrics div {
  padding: 2px 14px;
  border-left: 1px solid var(--line-soft);
}

.bot-metrics dt {
  margin-bottom: 9px;
  color: #6f8590;
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.11em;
}

.bot-metrics dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  white-space: nowrap;
}

.host-panel {
  margin-top: 16px;
  padding: 20px 22px 23px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-kicker {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 0.6rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 580;
}

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

.host-metric {
  padding: 0 24px;
  border-left: 1px solid var(--line-soft);
}

.host-metric:first-child {
  padding-left: 0;
  border-left: 0;
}

.host-metric:last-child {
  padding-right: 0;
}

.host-metric-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 11px;
  font-family: var(--mono);
}

.host-metric-top span {
  color: var(--muted);
  font-size: 0.67rem;
  letter-spacing: 0.12em;
}

.host-metric-top strong {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 520;
}

.meter {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #14252d;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3dbbc8, var(--cyan));
  box-shadow: 0 0 14px rgba(93, 227, 239, 0.3);
}

.host-metric p {
  margin: 9px 0 0;
  color: #71848d;
  font-family: var(--mono);
  font-size: 0.6rem;
}

.lower-grid {
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
  margin-top: 16px;
}

.activity-panel,
.trend-panel {
  min-height: 300px;
  padding: 20px 22px;
}

.activity-list {
  border-top: 1px solid var(--line-soft);
}

.activity-row {
  display: grid;
  grid-template-columns: 10px 82px 128px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid rgba(77, 124, 139, 0.13);
  font-size: 0.74rem;
}

.activity-row time {
  color: #6f8590;
  font-family: var(--mono);
  font-size: 0.63rem;
}

.activity-row strong {
  color: var(--cyan);
  font-family: var(--mono);
  font-weight: 500;
}

.activity-row > span:last-child {
  color: #b1c1c7;
}

.activity-dot {
  width: 6px;
  height: 6px;
}

.activity-dot.level-warn {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(240, 186, 69, 0.45);
}

.activity-dot.level-error {
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 111, 113, 0.45);
}

.empty-state {
  padding: 30px 0;
  color: #71848d;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.trend-chart svg {
  display: block;
  width: 100%;
  min-height: 200px;
}

.chart-grid line {
  stroke: rgba(107, 153, 167, 0.18);
  stroke-dasharray: 3 7;
}

.trend-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.signalflow-line {
  stroke: var(--cyan);
  filter: drop-shadow(0 0 5px rgba(93, 227, 239, 0.35));
}

.lexi-line {
  stroke: var(--amber);
  filter: drop-shadow(0 0 5px rgba(240, 186, 69, 0.28));
}

.chart-legend {
  display: flex;
  gap: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-dot.cyan {
  background: var(--cyan);
  box-shadow: none;
}

.legend-dot.amber {
  background: var(--amber);
  box-shadow: none;
}

.footer {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding: 18px 4px 0;
  color: #526a75;
  font-size: 0.56rem;
}

.skeleton-card {
  min-height: 194px;
  animation: pulse 1.6s ease-in-out infinite;
}

.login-page {
  display: grid;
  place-items: center;
}

.login-shell {
  position: relative;
  width: min(440px, calc(100% - 32px));
  padding: 54px 0;
}

.login-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(26, 58, 67, 0.18), transparent 42%),
    rgba(7, 16, 21, 0.94);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.45);
}

.login-mark {
  display: flex;
  gap: 5px;
  margin-bottom: 28px;
}

.login-mark span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--cyan);
}

.login-mark span:nth-child(2) {
  opacity: 0.65;
}

.login-mark span:nth-child(3) {
  opacity: 0.32;
}

.login-card h1 {
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.login-copy {
  margin-bottom: 26px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

.login-card form {
  display: grid;
  gap: 17px;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: #a9bbc2;
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #29434e;
  border-radius: 5px;
  outline: none;
  color: var(--text);
  background: #071117;
}

.login-card input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(93, 227, 239, 0.1);
}

.primary-button {
  min-height: 47px;
  border: 1px solid #63eaf1;
  border-radius: 5px;
  color: #001014;
  background: var(--cyan);
  font-weight: 650;
  cursor: pointer;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-error {
  min-height: 18px;
  margin: -5px 0;
  color: var(--red);
  font-size: 0.75rem;
}

.security-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 0;
  color: #667d86;
  font-family: var(--mono);
  font-size: 0.61rem;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .bot-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

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

  .host-metric:nth-child(3) {
    padding-left: 0;
    border-left: 0;
  }
}

@media (max-width: 650px) {
  .shell {
    width: min(100% - 24px, 1500px);
    padding-top: 22px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .updated {
    width: 100%;
  }

  .bot-card-header,
  .bot-card-body,
  .host-panel,
  .activity-panel,
  .trend-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .bot-card-body {
    grid-template-columns: 1fr;
  }

  .bot-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 0;
  }

  .bot-metrics div:nth-child(odd) {
    border-left: 0;
    padding-left: 0;
  }

  .host-grid {
    grid-template-columns: 1fr;
    gap: 19px;
  }

  .host-metric,
  .host-metric:nth-child(3) {
    padding: 0 0 19px;
    border-bottom: 1px solid var(--line-soft);
    border-left: 0;
  }

  .activity-row {
    grid-template-columns: 8px 64px 96px minmax(0, 1fr);
    gap: 7px;
    font-size: 0.64rem;
  }

  .footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
