@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  /* theant.space brand on light surfaces */
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --ink-900: #020817;
  --ink-800: #030712;
  --ink-700: #0a101d;
  --bg-page: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --card-bg: #ffffff;
  --surface: #f8fafc;
  --surface-muted: #f1f5f9;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning-bg: #fef3c7;
  --warning: #d97706;
  --info-bg: #eef2ff;
  --info: #4f46e5;
}

body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Soft page wash so pure white cards read clearly */
body:not(.login-page) .main-content {
  background: #f8fafc;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* App shell */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 16rem;
  flex-shrink: 0;
  background: var(--ink-900);
  color: #cbd5e1;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.sidebar-brand-text p {
  margin: 0;
}

.sidebar-brand-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: #94a3b8;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-group-label {
  margin: 0 0 0.25rem;
  padding: 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #cbd5e1;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--ink-700);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--brand-600);
  color: #fff;
}

.nav-link svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-footer {
  border-top: 1px solid var(--ink-700);
  padding: 1rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-email {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  margin: 0;
  font-size: 0.6875rem;
  color: #94a3b8;
}

.main-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

.page-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink-900);
}

.page-header .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-body {
  padding: 1.5rem 2rem 2.5rem;
}

/* Cards & panels */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-900);
}

.card-body {
  padding: 1.25rem;
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-900);
}

/* Forms */

label {
  display: block;
  margin-bottom: 0.875rem;
  font-size: 0.875rem;
}

label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
}

label small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  line-height: 1.4;
}

input[type='text'],
input[type='url'],
input[type='password'],
input[type='email'],
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 1rem;
}

/* Run mode tabs */

.run-mode-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border-radius: 0.625rem;
}

.run-mode-tab {
  padding: 0.45rem 0.875rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}

button.run-mode-tab:hover,
button.run-mode-tab:focus {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

button.run-mode-tab.active,
button.run-mode-tab.active:hover,
button.run-mode-tab.active:focus {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(11, 18, 32, 0.08);
}

.batch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
}

.batch-toolbar-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.batch-toolbar-actions {
  display: flex;
  gap: 0.375rem;
}

.batch-script-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.batch-script-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  cursor: pointer;
}

.batch-script-item:hover {
  border-color: var(--brand-500);
}

.batch-script-item input {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.batch-script-name {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.batch-script-meta {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.context-panel {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.context-panel-title {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

.context-panel-help {
  margin: 0 0 0.875rem;
  font-size: 0.8125rem;
}

.context-panel code {
  font-size: 0.75rem;
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
}

.context-vars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.context-var-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.context-var-row input {
  min-width: 0;
}

.context-add-btn {
  margin-top: 0.25rem;
}

.import-panel {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
  background: var(--card-bg);
}

.import-panel-title {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 700;
}

.import-panel-help {
  margin: 0 0 0.875rem;
  font-size: 0.8125rem;
}

.conversation-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  min-height: 8rem;
}

.actions-inline {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.adhoc-preview-list {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.adhoc-preview-list ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

/* Buttons */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

button:hover,
.btn:hover {
  background: var(--brand-700);
  text-decoration: none;
  color: #fff;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary,
.btn.secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover,
.btn.secondary:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: #cbd5e1;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #dc2626;
}

button.sm {
  padding: 0.35rem 0.625rem;
  font-size: 0.8125rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.filter-field {
  margin: 0;
  min-width: 0;
}

.filter-field span {
  margin-bottom: 0.25rem;
}

.filter-search {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.filter-field select,
.filter-field input[type='search'] {
  min-width: 8rem;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  padding-bottom: 0.05rem;
}

.filter-meta {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8125rem;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0.875rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-muted);
}

tbody tr:hover {
  background: var(--surface-muted);
}

td.actions-cell {
  white-space: nowrap;
}

td.actions-cell button,
td.actions-cell .btn {
  margin-right: 0.25rem;
}

/* Modal */

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.45);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(40rem, 100%);
  max-height: min(85vh, 40rem);
  background: var(--card-bg);
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(11, 18, 32, 0.18);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
}

.modal-header .muted {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.preview-turns {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-turn {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.preview-turn-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.preview-turn-block + .preview-turn-block {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.preview-turn-role {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-600);
  margin-bottom: 0.25rem;
}

.preview-turn-block p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Status badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.pass {
  background: var(--success-bg);
  color: var(--success);
}

.badge.fail {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.running {
  background: var(--info-bg);
  color: var(--info);
}

.badge.error {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Messages */

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.success {
  color: var(--success);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty {
  color: var(--text-subtle);
  font-style: italic;
  padding: 1.5rem;
  text-align: center;
}

/* Turn editor */

.turn-row {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0;
  margin-bottom: 0.75rem;
  background: var(--surface-muted);
  overflow: hidden;
}

.turn-row .turn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--card-bg);
  border-bottom: 1px solid transparent;
}

.turn-row:not(.is-collapsed) .turn-header {
  border-bottom-color: var(--border);
}

.turn-row .collapsible-turn-body {
  padding: 1rem;
}

.turn-toggle {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
}

/* Collapsible turns (shared) */

.collapsible-turn-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

button.collapsible-turn-toggle {
  background: transparent;
  color: inherit;
  font-weight: inherit;
  border-radius: 0;
}

button.collapsible-turn-toggle:hover,
button.collapsible-turn-toggle:focus,
button.collapsible-turn-toggle:active {
  background: transparent;
  color: inherit;
  box-shadow: none;
}

.transcript-turn-header.collapsible-turn-toggle:hover,
.transcript-turn-header.collapsible-turn-toggle:focus,
.transcript-turn-header.collapsible-turn-toggle:active {
  background: var(--surface-muted);
  color: inherit;
}

.transcript-turn-fail .transcript-turn-header.collapsible-turn-toggle:hover,
.transcript-turn-fail .transcript-turn-header.collapsible-turn-toggle:focus,
.transcript-turn-fail .transcript-turn-header.collapsible-turn-toggle:active {
  background: var(--danger-bg);
}

.collapsible-turn-toggle:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

.collapsible-turn-heading {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.collapsible-turn-title,
.turn-label {
  font-weight: 600;
  color: var(--text);
}

.collapsible-turn-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.collapsible-turn-preview {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsible-turn.is-collapsed .collapsible-turn-preview {
  display: block;
}

.collapsible-turn:not(.is-collapsed) .collapsible-turn-preview {
  display: none;
}

.collapsible-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.collapsible-turn.is-collapsed .collapsible-chevron {
  transform: rotate(-90deg);
}

.collapsible-turn-body {
  display: block;
}

.collapsible-turn.is-collapsed .collapsible-turn-body {
  display: none;
}

.turn-toggle .collapsible-chevron {
  margin-right: 0.375rem;
}

.turn-toggle .turn-label {
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.turn-toggle .collapsible-turn-preview {
  flex: 1;
  min-width: 0;
}

.turn-row:not(.is-collapsed) .turn-toggle .collapsible-turn-preview {
  display: none;
}

/* Run results */

.run-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface-muted);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.score-big {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--brand-600);
}

.turn-result {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.turn-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
}

.turn-result-body {
  padding: 0.875rem 1rem;
  display: grid;
  gap: 0.75rem;
}

.turn-field label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.turn-field .value {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.turn-field .value.actual {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
}

/* Collapsible sections */

.section-panel[hidden] {
  display: none !important;
}

/* Slide-in side panel (scripts editor, etc.) */

body.slide-panel-open {
  overflow: hidden;
}

.slide-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.35);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.slide-panel-backdrop.is-visible {
  opacity: 1;
}

.slide-panel-backdrop[hidden] {
  display: none !important;
}

.slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(36rem, 100vw);
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(11, 18, 32, 0.08);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.slide-panel.is-open {
  transform: translateX(0);
}

.slide-panel[hidden] {
  display: none !important;
}

.slide-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.slide-panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
}

.slide-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 1.25rem 1.5rem;
}

.editor-panel .import-panel {
  margin-top: 0.25rem;
}

/* Transcript side panel */

body.transcript-open {
  overflow: hidden;
}

.transcript-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.35);
  z-index: 40;
}

.transcript-backdrop[hidden] {
  display: none !important;
}

.transcript-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(32rem, 100vw);
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(11, 18, 32, 0.08);
}

.transcript-panel[hidden] {
  display: none !important;
}

.transcript-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.transcript-panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
}

.transcript-panel-header .muted {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
}

.transcript-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.transcript-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem 1.25rem;
  overflow: hidden;
}

.transcript-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.25rem;
}

.transcript-turn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card-bg);
  margin-bottom: 0.875rem;
}

.transcript-turn:last-child {
  margin-bottom: 0;
}

.transcript-turn-fail {
  border-color: #fecaca;
  background: #fffbfb;
}

.transcript-turn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--surface-muted);
  border: 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.transcript-turn.is-collapsed .transcript-turn-header {
  border-bottom: 0;
}

.transcript-turn:not(.is-collapsed) .transcript-turn-header .collapsible-turn-preview {
  display: none;
}

.transcript-turn-fail .transcript-turn-header {
  background: var(--danger-bg);
  border-bottom-color: #fecaca;
}

.transcript-line + .transcript-line {
  border-top: 1px solid var(--border);
}

.transcript-line {
  padding: 0.75rem 0.875rem;
}

.transcript-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.transcript-message {
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-expected {
  color: var(--text-muted);
}

.transcript-actual {
  color: var(--text);
}

.transcript-message-fail,
.transcript-fail {
  color: var(--danger);
  font-weight: 600;
}

.actions-cell-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: flex-end;
}

/* Login — matches theant.space dark indigo theme */

.login-page {
  min-height: 100vh;
  background: var(--bg-page);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  padding: 3rem;
  background:
    radial-gradient(ellipse 70% 55% at 15% 10%, rgba(99, 102, 241, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 85%, rgba(79, 70, 229, 0.22), transparent 50%),
    linear-gradient(165deg, #020817 0%, #030712 45%, #0a101d 100%);
  color: #e2e8f0;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.login-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 70% at 40% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}

.login-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 26rem;
}

.login-brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.25rem;
}

.login-brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}

.login-brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-brand-eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-500);
}

.login-brand-headline {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, 2.5vw, 2.35rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: #fff;
}

.login-brand-copy {
  margin: 0 0 1.75rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.login-brand-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-brand-points li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #cbd5e1;
}

.login-brand-points li::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--brand-500);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.login-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(ellipse 55% 40% at 85% 0%, rgba(99, 102, 241, 0.08), transparent 60%),
    var(--bg-page);
}

.login-card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 32px rgba(15, 23, 42, 0.08);
}

.login-card-header {
  margin-bottom: 1.5rem;
}

.login-card-logo {
  display: none;
  margin-bottom: 1rem;
}

.login-card-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-card-header .muted {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
}

.login-card label {
  margin-bottom: 1rem;
}

.login-card input {
  width: 100%;
}

.login-error {
  margin: 0 0 1rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.7rem 1rem;
  font-size: 0.9375rem;
  background: var(--brand-600);
}

.login-submit:hover {
  background: var(--brand-700);
}

.login-submit.is-loading {
  cursor: wait;
}

.login-footnote {
  margin: 0;
  font-size: 0.75rem;
}

.login-footnote a {
  color: var(--brand-500);
}

@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    display: none;
  }

  .login-card-logo {
    display: flex;
  }

  .login-main {
    min-height: 100vh;
    padding: 1.5rem 1.25rem;
  }

  .login-card {
    padding: 1.5rem;
  }
}

/* Legacy layout (fallback) */

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

header.top h1 {
  margin: 0;
  font-size: 1.35rem;
}

nav.links {
  display: flex;
  gap: 12px;
  align-items: center;
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }

  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .nav-group {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-group-label {
    width: 100%;
  }

  .main-content {
    height: auto;
  }

  .page-header,
  .page-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  td.actions-cell {
    white-space: normal;
  }

  td.actions-cell button,
  td.actions-cell .btn {
    margin-bottom: 0.25rem;
  }
}
