:root {
  --bg-top: #d8e4f6;
  --bg-bottom: #f0f4fb;
  --bg-accent: rgba(176, 215, 255, 0.82);
  --pane: rgba(255, 255, 255, 0.72);
  --pane-soft: rgba(247, 249, 253, 0.88);
  --line: rgba(106, 125, 155, 0.24);
  --input-line: rgba(127, 147, 179, 0.3);
  --input-bg: rgba(255, 255, 255, 0.86);
  --soft-bg: rgba(255, 255, 255, 0.72);
  --text-primary: #1a2433;
  --text-secondary: #64758b;
  --blue: #0a84ff;
  --blue-strong: #0077ed;
  --bubble-in: #eceef2;
  --bubble-out: #0a84ff;
  --danger: #d93025;
  --shadow-lg: 0 32px 80px rgba(20, 37, 63, 0.2);
  --shadow-sm: 0 8px 24px rgba(20, 37, 63, 0.1);
}

[data-theme="dark"] {
  --bg-top: #101622;
  --bg-bottom: #060a13;
  --bg-accent: rgba(36, 75, 130, 0.65);
  --pane: rgba(20, 27, 39, 0.76);
  --pane-soft: rgba(20, 27, 39, 0.92);
  --line: rgba(127, 152, 191, 0.24);
  --input-line: rgba(127, 152, 191, 0.34);
  --input-bg: rgba(17, 25, 39, 0.9);
  --soft-bg: rgba(17, 25, 39, 0.72);
  --text-primary: #e9eef8;
  --text-secondary: #9aabca;
  --bubble-in: #222e43;
  --bubble-out: #0076f4;
  --shadow-lg: 0 28px 70px rgba(2, 8, 18, 0.52);
  --shadow-sm: 0 8px 20px rgba(2, 8, 18, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family:
    "SF Pro Display", "SF Pro Text", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--text-primary);
}

body {
  position: relative;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      circle at 12% 8%,
      rgba(255, 255, 255, 0.92),
      transparent 40%
    ),
    radial-gradient(circle at 90% 18%, var(--bg-accent), transparent 36%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

[data-theme="dark"] .bg-gradient {
  background:
    radial-gradient(circle at 12% 8%, rgba(52, 90, 148, 0.26), transparent 40%),
    radial-gradient(circle at 90% 18%, rgba(22, 53, 99, 0.6), transparent 36%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.4) 0.6px, transparent 0.6px),
    radial-gradient(rgba(200, 216, 238, 0.45) 0.6px, transparent 0.6px);
  background-position:
    0 0,
    16px 16px;
  background-size: 24px 24px;
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 16px;
}

.top-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 15px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.glass-pane {
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  backdrop-filter: blur(32px) saturate(150%);
  background: var(--pane);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.hidden {
  display: none;
}

h1,
h2,
h3,
p,
pre {
  margin: 0;
}

.eyebrow {
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.74rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-secondary);
  line-height: 1.35;
}

.login-card {
  width: min(430px, 100%);
  border-radius: 34px;
  margin: 8vh auto 0;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: enter 0.55s cubic-bezier(0.19, 0.8, 0.2, 1);
}

.app-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px;
  background: linear-gradient(140deg, var(--blue), #43b2ff);
  box-shadow: 0 18px 35px rgba(10, 132, 255, 0.38);
}

.login-header h1 {
  margin-top: 4px;
  font-size: 2rem;
  line-height: 1.1;
}

.login-header .subtitle {
  margin-top: 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--input-line);
  background: var(--input-bg);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 0.96rem;
  outline: none;
  padding: 11px 13px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(10, 132, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.btn {
  border: 0;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: saturate(108%);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(130deg, var(--blue-strong), #38a7ff);
  box-shadow: 0 14px 26px rgba(0, 122, 255, 0.34);
}

.btn-soft {
  border: 1px solid var(--input-line);
  color: var(--text-primary);
  background: var(--soft-bg);
}

.btn-xs {
  padding: 6px 9px;
  font-size: 0.74rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.apple-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.apple-switch input {
  display: none;
}

.apple-switch-track {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(125, 138, 160, 0.38);
  box-shadow: inset 0 0 0 1px rgba(113, 126, 149, 0.22);
  transition: background 0.2s ease;
}

.apple-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 12px rgba(15, 27, 46, 0.18);
  transition: transform 0.2s ease;
}

.apple-switch input:checked + .apple-switch-track {
  background: linear-gradient(135deg, #37d67a, #24b364);
}

.apple-switch input:checked + .apple-switch-track::after {
  transform: translateX(20px);
}

.apple-switch-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.error-text {
  min-height: 1.1rem;
  color: var(--danger);
  font-size: 0.84rem;
}

.messages-layout {
  width: 100%;
  height: calc(100vh - 90px);
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.messages-layout > .sidebar-pane {
  flex: 0 1 380px;
  width: 100%;
  max-width: 380px;
}

.messages-layout > .conversation-pane {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.messages-layout > .details-pane {
  flex: 0 1 340px;
  min-width: 280px;
  max-width: 340px;
}

.pane {
  border-radius: 28px;
  overflow: auto;
  min-height: 0;
}

.sidebar-pane {
  display: flex;
  flex-direction: column;
}

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

.sidebar-title-wrap h2 {
  margin-top: 3px;
  font-size: 1.45rem;
  letter-spacing: -0.015em;
}

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

.sidebar-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  border: 1px solid;
  font-weight: 600;
}

.status-pill.online {
  color: #0f7a43;
  background: rgba(77, 214, 140, 0.14);
  border-color: rgba(29, 178, 102, 0.28);
}

.status-pill.degraded {
  color: #a26608;
  background: rgba(255, 196, 61, 0.18);
  border-color: rgba(219, 155, 9, 0.35);
}

.status-pill.offline {
  color: #a01f2e;
  background: rgba(238, 85, 104, 0.14);
  border-color: rgba(215, 53, 81, 0.32);
}

.details-subhead {
  margin-top: 8px;
}

.request-log-section {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.glass-inline {
  margin: 10px 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--pane-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.test-form {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.testing-console {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px 0;
}

.testing-console-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.52),
    rgba(255, 255, 255, 0.24)
  );
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 102px;
  flex: 1 1 calc(33.333% - 10px);
  min-width: 200px;
}

[data-theme="dark"] .testing-console-card {
  background: linear-gradient(
    180deg,
    rgba(34, 45, 67, 0.88),
    rgba(19, 28, 43, 0.72)
  );
}

.testing-scenario-summary {
  font-size: 0.92rem;
  line-height: 1.4;
}

.testing-expected-code {
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(10, 132, 255, 0.1);
  border: 1px dashed rgba(10, 132, 255, 0.24);
  overflow-wrap: anywhere;
}

.testing-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.request-log {
  padding: 0 16px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.request-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--pane-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.request-item pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.artifact-image {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
}

@media (max-width: 1180px) {
  .testing-console-card {
    flex-basis: 100%;
  }
}

.request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.request-meta,
.event-time {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.request-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.request-badge.ok {
  color: #0f7a43;
  background: rgba(77, 214, 140, 0.14);
}

.request-badge.error {
  color: #a01f2e;
  background: rgba(238, 85, 104, 0.14);
}

.search-wrap {
  margin: 10px 16px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  padding: 4px 9px;
  border: 1px solid var(--input-line);
  background: var(--soft-bg);
  flex-direction: row;
}

.search-icon {
  color: var(--text-secondary);
  font-size: 30px;
  line-height: 1;
}

.search-wrap input {
  border: 0;
  padding: 7px 2px;
  background: transparent;
  box-shadow: none;
}

.chat-list {
  min-height: 0;
  overflow: auto;
  padding: 20px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-item {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.chat-item:hover {
  transform: translateY(-1px);
  border-color: rgba(53, 143, 235, 0.32);
}

.chat-item.active {
  border-color: rgba(53, 143, 235, 0.44);
  background: rgba(227, 240, 255, 0.9);
}

[data-theme="dark"] .chat-item {
  background: rgba(22, 33, 50, 0.75);
}

[data-theme="dark"] .chat-item.active {
  background: rgba(27, 61, 100, 0.66);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  background: linear-gradient(145deg, #7ba8d9, #8a95bd);
}

.chat-main {
  min-width: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
}

.chat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-name {
  min-width: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.chat-subtitle {
  min-width: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-step {
  font-size: 0.72rem;
  color: #5b6f8f;
}

.unread-pill {
  margin-left: 8px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--blue-strong);
}

.conversation-pane {
  display: flex;
  flex-direction: column;
}

.conversation-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.conversation-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  background: linear-gradient(145deg, #6b8bc2, #8ca3d9);
}

.conversation-title-wrap h2 {
  margin-top: 4px;
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(124, 146, 177, 0.28);
  background: var(--soft-bg);
  color: #5f7392;
  font-size: 0.73rem;
  font-weight: 600;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bubble {
  position: relative;
  width: fit-content;
  max-width: min(76%, 620px);
  border-radius: 22px;
  padding: 9px 12px;
  line-height: 1.32;
  font-size: 0.93rem;
  animation: messageIn 0.22s ease;
}

.bubble.buyer {
  align-self: flex-start;
  color: var(--text-primary);
  background: var(--bubble-in);
}

.bubble.buyer::after {
  content: "";
  position: absolute;
  left: -4px;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: var(--bubble-in);
  border-bottom-right-radius: 12px;
  clip-path: polygon(0 100%, 100% 100%, 100% 0);
}

.bubble.bot {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(150deg, var(--bubble-out), #2e98ff);
}

.bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.render-hint {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.bubble.bot::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: 0;
  width: 12px;
  height: 12px;
  background: #178dff;
  border-bottom-left-radius: 12px;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}

.bubble .meta {
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.72;
}

.composer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--pane-soft);
}

.composer textarea {
  flex: 1 1 auto;
}

.composer textarea {
  min-height: 46px;
  max-height: 140px;
  resize: vertical;
  border-radius: 18px;
  padding: 11px 14px;
}

.details-pane {
  display: flex;
  flex-direction: column;
}

.details-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.details-head h3 {
  margin-top: 4px;
  font-size: 1.05rem;
}

.events {
  min-height: 70px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-item {
  border-radius: 12px;
  border: 1px solid rgba(121, 141, 171, 0.24);
  background: var(--soft-bg);
  box-shadow: var(--shadow-sm);
  padding: 10px;
}

.event-item strong {
  display: block;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #54739a;
}

.event-item pre {
  margin-top: 8px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--text-primary);
}

.event-time {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.empty {
  border-radius: 12px;
  background: var(--soft-bg);
  color: var(--text-secondary);
  border: 1px dashed rgba(121, 141, 171, 0.32);
  padding: 12px;
  font-size: 0.84rem;
}

.cdk-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cdk-header {
  border-radius: 24px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cdk-header h2 {
  margin-top: 3px;
}

.cdk-header-actions {
  display: flex;
  gap: 8px;
}

.cdk-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-card {
  flex: 1 1 calc(25% - 10px);
}

.stat-card {
  border-radius: 18px;
  padding: 14px;
}

.stat-card h3 {
  margin-top: 6px;
  font-size: 1.55rem;
}

.cdk-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cdk-grid > .cdk-panel:first-child {
  flex: 0 1 420px;
  min-width: 300px;
}

.cdk-grid > .cdk-panel:last-child {
  flex: 1 1 420px;
  min-width: 0;
}

.cdk-panel {
  border-radius: 24px;
  padding: 14px;
  min-height: 0;
}

.panel-head {
  margin-bottom: 12px;
}

.panel-head h3 {
  font-size: 1rem;
}

.panel-head-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.bulk-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inline-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-select {
  border-radius: 10px;
  border: 1px solid var(--input-line);
  color: var(--text-primary);
  background: var(--input-bg);
  padding: 6px 10px;
}

.cdk-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cdk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.cdk-table th,
.cdk-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.cdk-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--pane-soft);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.badge-status {
  font-size: 0.68rem;
  text-transform: uppercase;
}

@keyframes enter {
  from {
    transform: translateY(10px) scale(0.985);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes messageIn {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1260px) {
  body {
    overflow: auto;
  }

  .messages-layout {
    height: auto;
    flex-wrap: wrap;
  }

  .messages-layout > .sidebar-pane {
    min-width: 280px;
    max-width: none;
  }

  .messages-layout > .conversation-pane {
    flex: 1 1 0;
  }

  .messages-layout > .details-pane {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
    min-height: 280px;
  }

  .cdk-grid {
    flex-direction: column;
  }

  .cdk-grid > .cdk-panel:first-child,
  .cdk-grid > .cdk-panel:last-child {
    min-width: 0;
    flex: 1 1 auto;
  }
}

@media (max-width: 900px) {
  .shell {
    padding: 10px;
  }

  .messages-layout {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .messages-layout > .sidebar-pane,
  .messages-layout > .details-pane {
    min-width: 0;
    max-width: none;
  }

  .sidebar-pane {
    min-height: 300px;
  }

  .conversation-pane {
    min-height: 60vh;
  }

  .bubble {
    max-width: 88%;
  }

  .cdk-stats {
    flex-wrap: wrap;
  }

  .stat-card {
    flex-basis: calc(50% - 10px);
  }

  .cdk-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .cdk-header-actions {
    flex-wrap: wrap;
  }

  .composer {
    flex-direction: column;
    align-items: stretch;
  }
}

.hidden,
.messages-layout.hidden,
.login-card.hidden {
  display: none !important;
}
