:root {
  --cd-navy: #0b1f33;
  --cd-navy-2: #123049;
  --cd-teal: #0f9d8e;
  --cd-teal-2: #0b7c71;
  --cd-bg: #f3f5f8;
  --cd-card: #ffffff;
  --cd-text: #1b2430;
  --cd-muted: #5b6776;
  --cd-line: #e3e8ef;
  --cd-danger: #c0392b;
  --cd-warn: #b7791f;
  --sidebar-w: 260px;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cd-bg);
  color: var(--cd-text);
}
a { color: var(--cd-teal-2); }
.cd-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--cd-navy) 0%, var(--cd-navy-2) 100%);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
  display: flex;
  flex-direction: column;
}
.cd-brand { letter-spacing: .04em; }
.cd-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: .55rem;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}
.login-brand {
  display: flex;
  justify-content: center;
}
.login-brand img {
  display: block;
  border-radius: .75rem;
  max-width: 100%;
  height: auto;
}
.cd-nav a {
  color: #c9d6e3;
  border-radius: .5rem;
  padding: .45rem .75rem;
  display: flex;
  gap: .55rem;
  align-items: center;
  text-decoration: none;
}
.cd-nav a:hover, .cd-nav a.active { background: rgba(255,255,255,.08); color: #fff; }
.cd-nav-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
  padding: .35rem .75rem .15rem;
}
.cd-sidebar-profile {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.cd-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.cd-main.has-chrome {
  min-height: 100vh;
}
@media (min-width: 992px) {
  .cd-main { margin-left: var(--sidebar-w); }
}
.cd-main-chrome {
  position: sticky;
  top: 0;
  z-index: 1020;
}
.cd-topbar {
  background: #fff;
  border-bottom: 1px solid var(--cd-line);
}
.cd-body { flex: 1 0 auto; }
.cd-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .85rem 1.25rem;
  background: #fff;
  border-top: 1px solid var(--cd-line);
  color: var(--cd-muted);
  font-size: .85rem;
}
.cd-footer-meta { color: var(--cd-muted); }
.cd-card {
  background: var(--cd-card);
  border: 1px solid var(--cd-line);
  border-radius: .9rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.kpi .value { font-size: 1.45rem; font-weight: 700; }
.kpi .label { color: var(--cd-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.badge-intent { background: #e7f6f4; color: #0b7c71; }
.msg-bubble {
  max-width: 72%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
.msg-in { background: #fff; border: 1px solid var(--cd-line); }
.msg-out { background: #0f9d8e; color: #fff; }
.msg-agent { background: #123049; color: #fff; }
.login-wrap { max-width: 420px; }
.view-as { background: #fff4d6; border-bottom: 1px solid #f0d48a; }
.progress { height: .6rem; background: var(--cd-line); }
.progress-bar.bg-teal { background-color: var(--cd-teal) !important; }
.empty-state { color: var(--cd-muted); }
.table td, .table th { vertical-align: middle; }
pre.diff { font-size: .85rem; background: #0b1f33; color: #d7e3ef; padding: 1rem; border-radius: .6rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--cd-teal);
  box-shadow: 0 0 0 .2rem rgba(15,157,142,.15);
}
.btn-teal { background: var(--cd-teal); border-color: var(--cd-teal); color: #fff; }
.btn-teal:hover { background: var(--cd-teal-2); color: #fff; }
.cd-section-title {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cd-muted);
  margin-bottom: 1rem;
}
.cd-form .form-label { font-weight: 600; font-size: .875rem; }
.cd-form .form-text { color: var(--cd-muted); }
.cd-id-preview {
  font-size: .85em;
  background: var(--cd-bg);
  padding: .1rem .4rem;
  border-radius: .3rem;
}
.cd-form input[readonly] { background: var(--cd-bg); color: var(--cd-muted); }
.cd-meta { display: grid; gap: .65rem; }
.cd-meta > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; align-items: start; }
.cd-meta dt { margin: 0; color: var(--cd-muted); font-weight: 500; font-size: .85rem; }
.cd-meta dd { margin: 0; }
.transcript { max-height: 65vh; overflow: auto; }

/* Test chat / playground */
.playground {
  max-width: 860px;
  margin-inline: auto;
  width: 100%;
}
.playground-shell {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: min(72vh, 680px);
}
.playground-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--cd-line);
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
.playground-avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: .75rem;
  display: grid;
  place-items: center;
  background: rgba(15, 157, 142, .12);
  color: var(--cd-teal-2);
  flex-shrink: 0;
}
.playground-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: var(--cd-muted);
  background: var(--cd-bg);
  border: 1px solid var(--cd-line);
  border-radius: 999px;
  padding: .25rem .65rem;
  white-space: nowrap;
}
.playground-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--cd-teal);
  box-shadow: 0 0 0 .2rem rgba(15, 157, 142, .18);
}
.playground-log {
  flex: 1;
  min-height: 280px;
  max-height: none;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(circle at top right, rgba(15, 157, 142, .06), transparent 34%),
    linear-gradient(180deg, #f7f9fc 0%, #f3f5f8 100%);
  overflow: auto;
}
.playground-empty {
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--cd-text);
}
.playground-empty-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  margin-bottom: .85rem;
  background: #fff;
  border: 1px solid var(--cd-line);
  color: var(--cd-teal-2);
  font-size: 1.25rem;
}
.playground-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  max-width: 34rem;
}
.playground-chip {
  border: 1px solid var(--cd-line);
  background: #fff;
  color: var(--cd-text);
  border-radius: 999px;
  padding: .4rem .8rem;
  font-size: .85rem;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.playground-chip:hover {
  border-color: var(--cd-teal);
  color: var(--cd-teal-2);
  background: #e7f6f4;
}
.playground-row {
  display: flex;
  margin-bottom: .85rem;
}
.playground-row.is-you { justify-content: flex-end; }
.playground-row.is-bot,
.playground-row.is-error { justify-content: flex-start; }
.playground-row > div {
  max-width: min(78%, 34rem);
  min-width: 0;
}
.playground-row .msg-bubble {
  width: fit-content;
  max-width: 100%;
  min-width: 2.75rem;
}
.playground-row.is-you .msg-bubble {
  background: var(--cd-navy);
  color: #fff;
  border: none;
  border-bottom-right-radius: .35rem;
  margin-left: auto;
}
.playground-row.is-bot .msg-bubble {
  background: #fff;
  color: var(--cd-text);
  border: 1px solid var(--cd-line);
  border-bottom-left-radius: .35rem;
}
.playground-row.is-error .msg-bubble {
  background: #fff5f4;
  color: var(--cd-danger);
  border: 1px solid #f0c9c4;
}
.playground-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}
.playground-meta .badge {
  font-weight: 500;
  font-size: .7rem;
}
.playground-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .65rem;
  align-items: end;
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--cd-line);
  background: #fff;
}
.playground-input {
  width: 100%;
  max-width: 100%;
  resize: none;
  min-height: 2.6rem;
  max-height: 8rem;
  line-height: 1.4;
  padding-top: .65rem;
  padding-bottom: .65rem;
}
.playground-send {
  min-width: 5.5rem;
  white-space: nowrap;
}
.playground-log[data-empty="0"] #playground-empty { display: none; }

@media (max-width: 575px) {
  .playground-header { flex-direction: column; align-items: stretch; }
  .playground-pill { display: none; }
  .playground-row > div { max-width: 88%; }
}

/* Busy / wait feedback */
.btn.is-busy {
  position: relative;
  pointer-events: none;
  opacity: .85;
}
.btn.is-busy .cd-btn-label { opacity: 0; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cd-spin .6s linear infinite;
}
@keyframes cd-spin {
  to { transform: rotate(360deg); }
}

.cd-typing {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 1.25rem;
}
.cd-typing-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  animation: cd-bounce 1.2s ease-in-out infinite;
}
.cd-typing-dot:nth-child(2) { animation-delay: .15s; }
.cd-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes cd-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.cd-page-busy {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(11, 31, 51, .28);
  backdrop-filter: blur(1px);
}
.cd-page-busy.is-on { display: flex; }
.cd-page-busy-card {
  background: #fff;
  border: 1px solid var(--cd-line);
  border-radius: .9rem;
  padding: 1.1rem 1.35rem;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .12);
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--cd-text);
  font-weight: 600;
}
.cd-page-busy-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--cd-teal);
  border-right-color: transparent;
  border-radius: 50%;
  animation: cd-spin .6s linear infinite;
  flex-shrink: 0;
}

@media (max-width: 991px) {
  .cd-sidebar {
    position: relative;
    inset: auto;
    height: auto;
    width: 100%;
    overflow-y: visible;
  }
  .cd-main { margin-left: 0; }
}
