/* Admin — layout A (sesiones master-detail mockup) */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/Inter-400.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/Inter-500.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/Inter-600.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/Inter-700.woff2") format("woff2");
}

:root {
  --bg: #060b16;
  --bg-2: #0a1120;
  --surface: #0c1a33;
  --surface-soft: #0a1730;
  --line: #162b54;
  --line-strong: #274374;
  --text: #e8f0fc;
  --text-muted: #819ac4;
  --primary: #14b8a6;
  --primary-dim: #0f7f9a;
  --teal-glow: rgba(20, 184, 166, 0.25);
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-card: 0 14px 34px rgba(0, 0, 0, 0.45);
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at 18% 0%, #0a1d44 0%, transparent 42%),
    radial-gradient(circle at 100% 100%, #08183a 0%, transparent 42%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  color: var(--text);
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.85rem; }

/* —— Top bar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: var(--topbar-h);
  padding: 0 20px;
  background: linear-gradient(90deg, #071127 0%, #060f22 50%, #040b18 100%);
  border-bottom: 1px solid #1a2f5b;
  box-shadow: 0 8px 24px rgba(1, 5, 18, 0.45);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 32px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  background: transparent;
}

.brand-logo img {
  width: 34px;
  height: 34px;
  display: block;
}

.brand .title {
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #fff;
}

.brand .title-main {
  font-weight: 600;
}

.brand .title-suffix {
  font-weight: 400;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topnav-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.topnav-item img {
  opacity: 0.85;
}

.topnav-item:hover {
  color: var(--text);
  background: rgba(20, 184, 166, 0.08);
}

.topnav-item.active {
  color: #e6fffa;
}

.topnav-item.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.nav-icon-img {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

.topnav-item.active img {
  opacity: 1;
}

.topbar-utils {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-util-icons {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.topbar-util-icon {
  width: 28px;
  height: 28px;
  display: block;
  opacity: 0.9;
}

.icon-btn:hover {
  background: rgba(20, 184, 166, 0.08);
}

.icon-btn:hover .topbar-util-icon {
  opacity: 1;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 400;
}

.user-menu summary:hover {
  color: #e6fffa;
}

.user-menu-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
}

.user-menu summary::-webkit-details-marker { display: none; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dim), var(--primary));
  color: #031129;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 6px;
  z-index: 60;
}

.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
  background: rgba(20, 184, 166, 0.12);
}

/* —— Workspaces —— */
.workspace.hidden { display: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(400px, 44%) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 24px;
  min-height: calc(100vh - var(--topbar-h));
  align-items: start;
}

body.unauth .layout {
  grid-template-columns: minmax(340px, 420px);
  justify-content: center;
}

body.unauth .topnav,
body.unauth .topbar-utils {
  visibility: hidden;
}

body.unauth .topbar {
  justify-content: flex-start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.sessions-card {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h) - 48px);
}

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

.card-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.card-head-icon {
  color: var(--primary);
  font-size: 1.2rem;
}

.card-head-icon-img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
}

.card-head-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-left: 30px;
}

.filter-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.range-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.range-chip {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #0b1a3c;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.14s ease;
}

.range-chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.range-chip.active {
  background: rgba(20, 184, 166, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

input[type="date"],
input[type="text"],
input[type="password"],
.login-fields input {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.86rem;
  background: #0a1b3e;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter 0.12s ease, transform 0.1s ease;
}

.btn-primary {
  background: var(--primary);
  color: #031129;
}

.btn-outline {
  background: rgba(20, 184, 166, 0.06);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: rgba(20, 184, 166, 0.1);
}

.btn-ghost {
  background: #11254f;
  color: #b4c9ec;
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: #1a3d73;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.cat-chip {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #0b1a3c;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.14s ease;
}

.cat-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #031129;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-soft);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.table-wrap {
  flex: 1;
  overflow: auto;
  max-height: calc(100vh - 380px);
}

.sessions-table {
  table-layout: fixed;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th, td {
  padding: 11px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(22, 43, 84, 0.8);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #0d224c;
  color: #8db0e4;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th .sort-icon {
  margin-left: 4px;
  opacity: 0.7;
}

tbody tr {
  background: #091a3c;
  cursor: pointer;
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: #0f2755;
}

tbody tr.active {
  background: #132a52;
  box-shadow: inset 4px 0 0 0 var(--primary);
}

.col-calidad {
  width: 88px;
  text-align: center;
}

.col-mensajes,
.sessions-table td.col-mensajes,
.sessions-table th.col-mensajes {
  text-align: left;
  color: #c5d4ef;
}

body.unauth #analyticsWorkspace {
  display: none !important;
}

body.unauth #sessionsWorkspace {
  display: block !important;
}

body.unauth #sessionsWorkspace.hidden {
  display: block !important;
}

.sessions-table td.col-usuario {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th-resizable {
  position: relative;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}

.col-resize-handle:hover,
body.col-resize-dragging .col-resize-handle {
  background: rgba(20, 184, 166, 0.25);
}

body.col-resize-dragging {
  cursor: col-resize;
  user-select: none;
}

body.col-resize-dragging * {
  cursor: col-resize;
}

.quality-stars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 18px;
}

.quality-stars.loading .spinner-xs {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.quality-star {
  font-size: 0.95rem;
  line-height: 1;
  color: #3d5278;
}

.quality-stars.severity-low .quality-star.filled {
  color: #fbbf24;
}

.quality-stars.severity-medium .quality-star.filled {
  color: #f97316;
}

.quality-stars.severity-high .quality-star.filled {
  color: #dc2626;
}

.quality-stars.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.analysis-inline {
  padding: 12px 14px 14px 18px;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  background: transparent;
}

.analysis-inline-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.84rem;
  padding: 8px 0;
}

.analysis-inline-error {
  color: #fca5a5;
  font-size: 0.84rem;
  margin: 0;
}

.analysis-summary {
  margin: 0 0 10px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #c5d8f5;
}

.analysis-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.analysis-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(14, 116, 144, 0.12);
  color: #7dd3fc;
  font-size: 0.72rem;
  font-weight: 500;
}

.human-review-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(180, 83, 9, 0.2);
  color: #fcd34d;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.human-review-badge::before {
  content: "👤";
  font-size: 0.7rem;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #0a1733;
}

.table-footer-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.page-size-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.page-size-select {
  min-width: 56px;
  height: 32px;
  padding: 0 28px 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1a3c
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23819ac4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 8px center;
  color: #c5d8f5;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  appearance: none;
}

.page-size-select:hover {
  border-color: rgba(20, 184, 166, 0.45);
}

.page-size-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1a3c;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #031129;
  font-weight: 700;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* —— Detail panel —— */
.detail-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 48px);
  min-height: calc(100vh - var(--topbar-h) - 48px);
  overflow: hidden;
}

.detail-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.detail-header-main {
  flex: 1;
  min-width: 0;
}

.detail-header h3 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.detail-header h3 .card-head-icon-img {
  width: 30px;
  height: 30px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0;
  font-size: 0.88rem;
  color: #9cb8e0;
}

.detail-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.detail-meta-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #6b8fc4;
}

.detail-meta-icon--calendar {
  width: 18px;
  height: 18px;
}

.detail-meta-sep {
  width: 1px;
  height: 14px;
  margin: 0 14px;
  background: #2d4a7d;
  flex-shrink: 0;
}

.detail-options-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.detail-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-options {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #334f82;
  border-radius: 999px;
  transition: 0.2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* —— Transcript / analysis split (detail card) —— */
.detail-split {
  --split-handle-size: 10px;
  --detail-transcript-ratio: 0.7;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.detail-split-pane--transcript {
  flex: 0 0 calc((100% - var(--split-handle-size, 10px)) * var(--detail-transcript-ratio, 0.6));
  height: calc((100% - var(--split-handle-size, 10px)) * var(--detail-transcript-ratio, 0.6));
  min-height: 80px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #4a6a9a #06101f;
  padding: 14px 12px;
  display: block;
  background: #081428;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 0;
}

.detail-split-pane--transcript .chat-msg {
  margin-bottom: 16px;
}

.detail-split-pane--transcript .chat-msg:last-child {
  margin-bottom: 0;
}

.detail-split-pane--analysis {
  flex: 1 1 auto;
  min-height: 80px;
  min-width: 0;
  margin-top: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-scroll,
.detail-split-pane--transcript,
.analysis-panel.open .analysis-content {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

.pane-scroll::-webkit-scrollbar,
.detail-split-pane--transcript::-webkit-scrollbar,
.analysis-panel.open .analysis-content::-webkit-scrollbar {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
}

.pane-scroll::-webkit-scrollbar-track,
.detail-split-pane--transcript::-webkit-scrollbar-track,
.analysis-panel.open .analysis-content::-webkit-scrollbar-track {
  background: #06101f;
  border-radius: 6px;
}

.pane-scroll::-webkit-scrollbar-thumb,
.detail-split-pane--transcript::-webkit-scrollbar-thumb,
.analysis-panel.open .analysis-content::-webkit-scrollbar-thumb {
  background: #4a6a9a;
  border-radius: 6px;
  border: 2px solid #06101f;
  min-height: 40px;
}

.pane-scroll::-webkit-scrollbar-thumb:hover,
.detail-split-pane--transcript::-webkit-scrollbar-thumb:hover,
.analysis-panel.open .analysis-content::-webkit-scrollbar-thumb:hover {
  background: #6b92c4;
}

.pane-scroll::-webkit-scrollbar-corner,
.detail-split-pane--transcript::-webkit-scrollbar-corner,
.analysis-panel.open .analysis-content::-webkit-scrollbar-corner {
  background: #06101f;
}

.detail-split-handle {
  flex: 0 0 var(--split-handle-size);
  position: relative;
  z-index: 2;
  margin: 0;
  cursor: row-resize;
  touch-action: none;
  user-select: none;
  background: transparent;
}

.detail-split-handle::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: var(--line);
  transition: background 0.14s ease;
}

.detail-split-handle:hover::before,
.detail-split-handle:focus-visible::before,
.detail-split-handle.is-dragging::before {
  background: #3d5278;
}

.detail-split-handle-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f2755;
  color: #c5d8f5;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.detail-split-handle:hover .detail-split-handle-tooltip,
.detail-split-handle:focus-visible .detail-split-handle-tooltip,
.detail-split-handle.is-dragging .detail-split-handle-tooltip {
  opacity: 1;
}

body.detail-split-dragging {
  cursor: row-resize;
  user-select: none;
}

body.detail-split-dragging * {
  cursor: row-resize;
}

.detail-split .main-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: rgba(8, 20, 40, 0.72);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.detail-split .main-loading.visible {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #2c4f8d;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-xs {
  width: 14px;
  height: 14px;
  border-width: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 92%;
}

.chat-msg.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.chat-msg.user .chat-avatar {
  background: #1e4a8a;
  color: #bfdbfe;
}

.chat-msg.bot .chat-avatar {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.chat-msg.bot .chat-avatar img {
  width: 48px;
  height: 48px;
  display: block;
}

.chat-bubble {
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text);
}

.chat-msg.user .chat-bubble {
  background: #153a71;
  border: 1px solid #3366ad;
}

.chat-msg.bot .chat-bubble {
  background: #0f2848;
  border: 1px solid rgba(20, 184, 166, 0.45);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.08);
}

.chat-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-msg.user .chat-time { text-align: right; }

.chat-images {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chat-images img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a1b3e;
}

/* —— Suricata analysis (detail panel) —— */
.analysis-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b1d42;
  min-height: 0;
}

.analysis-panel.open .analysis-toggle .chevron { transform: rotate(180deg); }

.analysis-toggle {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border: none;
  background: #0f2755;
  color: #99b7e6;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.analysis-toggle .chevron { transition: transform 0.14s ease; }

.analysis-content {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #4a6a9a #06101f;
  padding: 12px 14px 14px;
  background: #081428;
}

.analysis-panel.open .analysis-content {
  display: block;
}

.analysis-panel.open {
  display: flex;
  flex-direction: column;
}

.detail-split:has(.analysis-panel:not(.open)) .detail-split-handle {
  cursor: default;
  pointer-events: none;
  opacity: 0.35;
}

.analysis-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 10px;
}

.analysis-detail-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #c5d8f5;
}

.analysis-detail-meta {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.analysis-detail .analysis-inline {
  margin: 0;
}

/* —— Login —— */
.stack { display: flex; flex-direction: column; gap: 10px; }

.login-fields {
  width: 100%;
}

.login-card {
  width: 100%;
}

.nav-icon-svg {
  color: #8db0e4;
}

.topnav-item.active .nav-icon-svg {
  color: #e6fffa;
}

.chat-workspace {
  padding: 0;
  min-height: calc(100vh - var(--topbar-h));
  overflow: auto;
  background: #f5f5f7;
}

.chat-workspace .chat-app-mount {
  min-height: calc(100vh - var(--topbar-h));
}

.chat-workspace .chat-app-mount .app-wrap {
  min-height: calc(100vh - var(--topbar-h));
  max-width: none;
}

.user-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.user-menu-dropdown button:hover {
  background: rgba(20, 184, 166, 0.1);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #11254f;
  border: 1px solid #2f4f87;
  color: #9fbae4;
  font-size: 0.8rem;
}
.status.error {
  background: #37172a;
  border-color: #7f2e50;
  color: #ffc3d2;
}

#listStatus { margin-left: auto; }

/* —— WIP workspaces —— */
/* ——— Reporting workspace ——— */
.reporting-layout {
  grid-template-columns: 1fr;
}

.reporting-card {
  grid-column: 1 / -1;
  max-width: 100%;
  overflow: hidden;
}

.reporting-filters {
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
}

.reporting-total {
  margin: 0 0 16px;
  font-size: 0.95rem;
}

.reporting-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 100%;
}

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

.reporting-panel {
  background: rgba(8, 18, 40, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  min-width: 0;
  max-width: 100%;
}

.reporting-panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #b9d8ff;
}

.reporting-outcome-note {
  margin: -4px 0 12px;
  font-size: 0.82rem;
}

.reporting-vchart-host {
  min-height: 220px;
  max-width: 100%;
  overflow: hidden;
}

.reporting-vchart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 100%;
  min-height: 200px;
  padding: 4px 0 0;
  box-sizing: border-box;
}

.reporting-outcome-chart {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.reporting-pie-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  margin: auto 0;
}

.reporting-pie {
  width: min(180px, 100%);
  height: min(180px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.reporting-pie-legend {
  display: grid;
  gap: 10px;
  margin: 0;
  min-width: 0;
}

.reporting-pie-legend-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
}

.reporting-pie-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  grid-row: 1 / span 2;
}

.reporting-pie-swatch--bot {
  background: #2ea043;
}

.reporting-pie-swatch--handoff {
  background: #d29922;
}

.reporting-pie-legend dt {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.reporting-pie-legend dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.reporting-vcol {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reporting-vbar-wrap {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px 4px 0 0;
}

.reporting-vbar {
  width: 72%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #5b9dff, #2f6fed);
}

.reporting-vbar--sessions {
  background: linear-gradient(180deg, #5b9dff, #2f6fed);
}

.reporting-vbar--users {
  background: linear-gradient(180deg, #2dd4bf, #14b8a6);
}

.reporting-vbar--bot {
  background: linear-gradient(180deg, #56d364, #2ea043);
}

.reporting-vbar--handoff {
  background: linear-gradient(180deg, #e3b341, #d29922);
}

.reporting-vlabel {
  font-size: clamp(0.55rem, 1.4vw, 0.72rem);
  color: var(--muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reporting-vvalue {
  font-size: clamp(0.6rem, 1.5vw, 0.75rem);
  font-variant-numeric: tabular-nums;
  color: #c9d9f0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reporting-outcome-stats {
  display: grid;
  gap: 10px;
  margin: 0;
}

.reporting-stat dt {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.reporting-stat dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

#analyticsWorkspace .layout {
  min-height: calc(100vh - var(--topbar-h));
  align-items: stretch;
  justify-content: stretch;
}


#suricataWorkspace .layout {
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
}

.wip-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / -1;
}

.wip-card {
  width: min(760px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.wip-card img {
  max-width: 560px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#suricataWorkspace .wip-card img {
  max-width: 320px;
  border-radius: 50%;
}

.wip-title {
  margin: 18px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #b9d8ff;
}

/* ——— Evals workspace ——— */
.evals-run-controls {
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.evals-run-controls select {
  min-width: 220px;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  cursor: pointer;
}

.eval-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.eval-badge--pass {
  background: rgba(46, 160, 67, 0.2);
  color: #3fb950;
}

.eval-badge--fail {
  background: rgba(248, 81, 73, 0.18);
  color: #f85149;
}

.eval-badge--running {
  background: rgba(88, 166, 255, 0.18);
  color: #58a6ff;
}

.eval-badge--queued {
  background: rgba(139, 148, 158, 0.18);
  color: #8b949e;
}

#evalsWorkspace .sessions-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#evalsWorkspace .sessions-card .table-shell {
  flex: 0 0 auto;
  max-height: 220px;
}

.evals-tasks-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.evals-section-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b949e;
}

.evals-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.evals-task-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.evals-task-row.active .evals-task-btn {
  border-color: var(--primary);
  background: rgba(88, 166, 255, 0.08);
}

.evals-task-btn {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
}

.evals-task-run-btn {
  flex-shrink: 0;
  padding: 7px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.evals-task-run-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.evals-task-btn-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#evalsWorkspace .detail-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.evals-right-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.evals-right-pane.hidden {
  display: none;
}

.evals-trials-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  margin-bottom: 12px;
  padding-right: 4px;
  flex-shrink: 0;
}

.evals-task-config {
  flex: 1;
  min-height: 200px;
  max-height: none;
  overflow: auto;
  margin-bottom: 0;
  padding: 14px 16px;
  border: 1px solid rgba(88, 166, 255, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(88, 166, 255, 0.06), rgba(46, 160, 67, 0.03));
}

.evals-trial-transcript {
  flex: 1;
  min-height: 160px;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
}

.evals-trial-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.evals-trial-btn.active {
  border-color: var(--primary);
  background: rgba(88, 166, 255, 0.08);
}

.evals-config-head {
  margin-bottom: 10px;
}

.evals-config-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.evals-config-id {
  font-size: 0.92rem;
  font-weight: 600;
  color: #79c0ff;
  background: rgba(88, 166, 255, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
}

.evals-config-meta {
  font-size: 0.78rem;
  color: var(--muted, #8b949e);
  letter-spacing: 0.02em;
}

.evals-config-desc {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted, #b1bac4);
  white-space: pre-wrap;
}

.evals-config-block + .evals-config-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(139, 148, 158, 0.18);
}

.evals-config-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b949e;
}

.evals-config-turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.evals-config-turn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.evals-config-turn-num {
  flex: 0 0 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(139, 148, 158, 0.2);
  color: #c9d1d9;
}

.evals-config-turn-text {
  flex: 1;
  font-size: 0.86rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.35);
  border: 1px solid rgba(139, 148, 158, 0.16);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.evals-grader-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.evals-grader-card {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.28);
  border: 1px solid rgba(139, 148, 158, 0.14);
}

.evals-grader-type {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d2a8ff;
  margin-bottom: 6px;
}

.evals-grader-expect {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.evals-grader-kv {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.evals-grader-key {
  color: #8b949e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.evals-grader-val {
  color: #e6edf3;
  word-break: break-word;
}

.evals-trial-duration {
  margin-left: 8px;
  font-size: 0.78rem;
  color: #8b949e;
}

.evals-trial-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.evals-trial-error,
.evals-grader-fail {
  color: #f85149;
  font-size: 0.9rem;
  margin: 6px 0;
}

/* Forms workspace */
#formsWorkspace .forms-layout {
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
}

#formsWorkspace .forms-list-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.forms-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.forms-form-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
}

.forms-form-btn:hover {
  border-color: rgba(88, 166, 255, 0.45);
}

.forms-form-btn.active {
  border-color: rgba(88, 166, 255, 0.8);
  background: rgba(88, 166, 255, 0.12);
}

.forms-form-id {
  font-weight: 650;
  font-size: 0.95rem;
}

.forms-form-meta {
  font-size: 0.8rem;
}

.forms-empty {
  margin: 8px 0;
}

#formsWorkspace .forms-detail-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#formsWorkspace .forms-table-shell {
  flex: 1;
  min-height: 0;
}

#formsWorkspace .forms-records-table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

#formsWorkspace .forms-records-table th,
#formsWorkspace .forms-records-table td {
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#formsWorkspace .forms-records-table tr.forms-record-row {
  cursor: pointer;
}

#formsWorkspace .forms-records-table tr.forms-record-row:hover td {
  background: rgba(56, 120, 255, 0.08);
}

.forms-version-row {
  margin-bottom: 10px;
}

.forms-pagination {
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  #formsWorkspace .forms-layout { grid-template-columns: 1fr; }
  .table-wrap { max-height: 280px; }
  .topbar-left { gap: 16px; }
  .topnav { gap: 2px; }
  .topnav-item { padding: 10px 10px; font-size: 0.84rem; gap: 8px; }
  .nav-icon-img { width: 24px; height: 24px; }
}
