:root {
  --ink: #10243d;
  --ink-soft: #1c3b5c;
  --accent: #0f766e;
  --accent-soft: #e6f5f3;
  --page: #e7eef5;
  --card: #ffffff;
  --line: #d7e0ea;
  --text: #172033;
  --muted: #5c6b80;
  --warn: #9f1239;
  --shadow: 0 18px 50px rgba(16, 36, 61, 0.08);
  color: var(--text);
  background: var(--page);
  font-family: "Segoe UI Variable Display", "Segoe UI", sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; }
h1 { font-size: 1.75rem; margin: 0; font-weight: 650; letter-spacing: -0.03em; }
h2 { font-size: 1rem; margin: 0 0 0.8rem; font-weight: 650; }
a { color: var(--ink-soft); text-decoration: none; }
p { margin: 0.35rem 0; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(15, 118, 110, 0.28), transparent 42%),
    linear-gradient(180deg, #14304f 0%, #0c1c30 100%);
  color: #e8eef6;
}
.sidebar-brand { display: flex; gap: 0.8rem; align-items: center; padding: 1.4rem 1.15rem 1.1rem; }
.brand-mark {
  width: 2.4rem; height: 2.4rem; flex: 0 0 2.4rem;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.brand-mark svg { width: 1.25rem; height: 1.25rem; }
.sidebar-kicker, .eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
.eyebrow { color: #0f766e; }
.sidebar-kicker, .login-hero .eyebrow { color: #8fd0c8; }
.sidebar-brand strong { display: block; font-size: 0.95rem; line-height: 1.25; font-weight: 650; }
.sidebar-nav { display: flex; flex-direction: column; padding: 0.4rem 0.75rem; gap: 0.25rem; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  color: #d5deea;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  font-size: 0.94rem;
}
.sidebar-nav a svg { width: 1.05rem; height: 1.05rem; opacity: 0.85; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 1rem 0.9rem 1.1rem; }
.sidebar-user { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 0.75rem; }
.sidebar-avatar {
  width: 2.15rem; height: 2.15rem; border-radius: 999px;
  display: grid; place-items: center;
  background: #0f766e; color: white; font-weight: 700;
}
.sidebar-user-name, .sidebar-user-email { margin: 0; }
.sidebar-user-name { font-size: 0.9rem; font-weight: 650; }
.sidebar-user-email { font-size: 0.75rem; color: #b7c4d4; word-break: break-all; }
.sidebar-logout, button.ghost {
  background: transparent;
  color: #e8eef6;
  border: 1px solid rgba(255, 255, 255, 0.22);
}
.workspace button.ghost { color: var(--ink); border-color: var(--line); background: white; }
.sidebar-logout { width: 100%; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 4.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.6rem;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar strong { font-size: 0.98rem; }
.topbar-kicker { margin: 0; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.region-chip {
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: var(--accent-soft);
  color: #115e59;
  font-size: 0.78rem;
  font-weight: 650;
}
.workspace-main { padding: 1.6rem; }

button {
  background: var(--ink);
  color: white;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1.15rem;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.8rem 0; }
.muted { color: var(--muted); }
.warn {
  color: var(--warn);
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.page-head { margin-bottom: 1.15rem; max-width: 46rem; }
.page-head .muted { margin-top: 0.35rem; }
.card, .table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 1.15rem 1.2rem; margin: 0 0 1rem; }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; margin: 0; }
th, td { text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
th { background: #f7fafc; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
.clickable tbody tr { cursor: pointer; }
.clickable tbody tr:hover { background: #f4f8fb; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.92rem; font-weight: 650; }
input, select {
  padding: 0.7rem 0.8rem;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  font: inherit;
  font-weight: 500;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: #0f766e; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; margin-bottom: 0.9rem; }
.check { flex-direction: row; align-items: center; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: #eef2f6;
  color: #334155;
}
.pill-ok { background: #dcfce7; color: #166534; }
.pill-draft { background: #fef3c7; color: #92400e; }
.pill-bad { background: #ffe4e6; color: #9f1239; }
.pill-muted { background: #eef2f6; color: #64748b; }
td button { padding: 0.4rem 0.75rem; border-radius: 10px; font-size: 0.82rem; }

.call-layout { display: grid; grid-template-columns: minmax(280px, 0.9fr) 1.2fr; gap: 1rem; align-items: start; }
.answer-panel { min-height: 22rem; display: flex; flex-direction: column; }
.answer-text {
  flex: 1;
  margin: 0.4rem 0 1rem;
  font-size: 1.2rem;
  line-height: 1.55;
  letter-spacing: -0.02em;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; }
.history-stats { grid-template-columns: repeat(6, 1fr); }
.softphone-card { margin-bottom: 1rem; }
.softphone-row {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}
.softphone-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.softphone-status { margin: 0.55rem 0 0; font-weight: 650; }
.softphone-status.ready { color: #166534; }
.softphone-status.ringing,
.softphone-status.in_call { color: #9a3412; }
.softphone-status.error { color: #991b1b; }
.softphone-status.offline,
.softphone-status.connecting { color: var(--muted); }
.clickable tbody tr.selected { background: #eef5fb; }
.history-turns { display: grid; gap: 0.85rem; }
.history-turn {
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: #f6f8fb;
}
.history-turn header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.45rem;
}
.history-turn p { margin: 0.25rem 0; line-height: 1.45; }
.stat {
  background: #f6f8fb;
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
}
.stat span { display: block; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 0.2rem; font-size: 0.95rem; font-weight: 650; }
.stat.latency-ok { background: #eefaf4; }
.stat.latency-warn { background: #fff8e6; }
.stat.latency-bad { background: #fff1f0; }
.chip-latency-ok { background: #d9f5e7; color: #166534; }
.chip-latency-warn { background: #ffe9b8; color: #92400e; }
.chip-latency-bad { background: #ffd4d1; color: #991b1b; }
.chip-clarify { background: #e8eef8; color: #1e3a5f; }
.history-stats { grid-template-columns: repeat(4, 1fr); }
.setting-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.setting-row p { font-weight: 500; }
.switch {
  appearance: none;
  width: 3rem;
  height: 1.7rem;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.34rem;
  height: 1.34rem;
  border-radius: 999px;
  background: white;
  transition: transform 0.15s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(1.28rem); }

.login-shell { min-height: 100vh; }
.login-frame { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 0.85fr; }
.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 3.5rem;
  color: white;
  background:
    radial-gradient(80% 60% at 10% 10%, rgba(15, 118, 110, 0.45), transparent 50%),
    linear-gradient(160deg, #184066 0%, #0c1c30 70%);
}
.login-hero h1 { font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: 0.98; max-width: 10ch; margin: 0.4rem 0 1rem; }
.login-hero p { max-width: 34rem; font-size: 1.12rem; color: #d7e3f0; }
.login-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 0.7rem; }
.login-points li {
  display: flex; gap: 0.7rem; align-items: center;
  color: #e8eef6; font-weight: 650;
}
.login-points span {
  width: 0.55rem; height: 0.55rem; border-radius: 999px; background: #5eead4;
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 2rem;
  background: #f3f7fb;
}
.login-card { width: min(420px, 100%); }
.login-card h1 { font-size: 2rem; margin: 0.2rem 0 0.4rem; }
.entra-link {
  margin-top: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.entra-link svg { width: 1.15rem; height: 1.15rem; }
.login-note { margin-top: 1rem; font-size: 0.88rem; }

.live-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) 1.4fr;
  gap: 1rem;
}
.live-session-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.live-session-list button {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 0.15rem;
  background: #f7fafc;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}
.live-session-list button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.live-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.live-phase {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7fafc;
}
.live-phase strong { display: block; }
.live-phase p { margin: 0.15rem 0 0; font-size: 0.85rem; }
.live-phase.hearing { border-color: #7eb6ff; background: #eef6ff; }
.live-phase.thinking,
.live-phase.matching { border-color: #e2c56b; background: #fff8e6; }
.live-phase.searching { border-color: #9b8cff; background: #f3f0ff; }
.live-phase.speaking { border-color: #5fbfb0; background: var(--accent-soft); }
.live-phase.dialing { border-color: #f0a060; background: #fff4eb; }
.live-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.6rem;
  min-width: 1.6rem;
}
.live-wave span {
  width: 3px;
  height: 28%;
  border-radius: 2px;
  background: #94a3b8;
  transform-origin: bottom;
}
.live-phase.listening .live-wave span:nth-child(3) { height: 45%; }
.live-phase.hearing .live-wave span,
.live-phase.speaking .live-wave span {
  background: var(--accent);
  animation: live-wave 0.9s ease-in-out infinite;
}
.live-phase.hearing .live-wave span:nth-child(1),
.live-phase.speaking .live-wave span:nth-child(1) { animation-delay: 0s; }
.live-phase.hearing .live-wave span:nth-child(2),
.live-phase.speaking .live-wave span:nth-child(2) { animation-delay: 0.12s; }
.live-phase.hearing .live-wave span:nth-child(3),
.live-phase.speaking .live-wave span:nth-child(3) { animation-delay: 0.24s; }
.live-phase.hearing .live-wave span:nth-child(4),
.live-phase.speaking .live-wave span:nth-child(4) { animation-delay: 0.36s; }
.live-phase.hearing .live-wave span:nth-child(5),
.live-phase.speaking .live-wave span:nth-child(5) { animation-delay: 0.48s; }
.live-phase.thinking .live-wave span,
.live-phase.matching .live-wave span {
  background: #c9a227;
  animation: live-pulse 1.1s ease-in-out infinite;
}
.live-phase.searching .live-wave span {
  background: #7c6bc4;
  animation: live-pulse 0.85s ease-in-out infinite;
}
@keyframes live-wave {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}
@keyframes live-pulse {
  0%, 100% { opacity: 0.35; height: 35%; }
  50% { opacity: 1; height: 70%; }
}

.live-transcript { display: grid; gap: 0.75rem; max-height: calc(100vh - 16rem); overflow: auto; }
.live-bubble {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: #f8fafc;
}
.live-bubble.caller { background: #eef6ff; border-color: #c9ddf5; }
.live-bubble.system { background: var(--accent-soft); border-color: #b7e0da; }
.live-bubble.follow-up {
  background: #f3f7fb;
  border-style: dashed;
  border-color: #c5d4e4;
}
.live-bubble.live-partial {
  border-style: dashed;
  opacity: 0.92;
}
.live-bubble.live-partial p::after {
  content: "▍
  animation: live-caret 1s step-end infinite;
}
@keyframes live-caret {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}
.live-bubble header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.live-bubble header strong { color: var(--text); }
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: rgba(16, 36, 61, 0.06);
  font-size: 0.75rem;
}
.chip-scenario { background: #e8f0fe; color: #1e3a5f; }
.chip-rag { background: #dcfce7; color: #166534; }
.chip-miss { background: #fee2e2; color: #991b1b; }
.chip-dial { background: #ffedd5; color: #9a3412; }
code {
  display: inline-block;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  word-break: break-all;
}

@media (max-width: 980px) {
  .login-frame, .call-layout, .stat-grid, .history-stats, .live-layout, .live-meta { grid-template-columns: 1fr; }
  .login-hero { min-height: 22rem; padding: 2rem; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
}
