:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #202124;
  --muted: #697180;
  --accent: #18191b;
  --danger: #c93434;
  --ok: #16824b;
  --border: #e1e4e8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  margin: 1rem;
  padding: 1.25rem;
  height: calc(100vh - 2rem);
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
}

.brand { font-weight: 700; font-size: 1.2rem; }
.brand-sub { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.85rem; }

nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.nav:hover { background: #f0f1f3; }
.nav.active { background: #f0f1f3; border-color: var(--border); color: #fff; }

.nav-group {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.nav-sub { font-size: 0.92rem; padding-left: 0.65rem; }

.sidebar-foot { font-size: 0.75rem; color: var(--muted); margin: 0 0 0.5rem; }
#btn-logout { margin-top: auto; }

body.signed-out .layout { display: none; }
body.signed-out .login-screen { display: flex; }

.login-screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  margin: 0;
}

.login-card h1 { margin: 0 0 0.35rem; font-size: 1.35rem; }
.login-error { color: var(--danger); }
.login-demo { margin-top: 1rem; }
body.role-agent-user [data-roles="org_admin"] { display: none !important; }

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.team-list { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.5rem; }

.team-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.team-row .meta { font-size: 0.8rem; color: var(--muted); }

.team-invite-form label { margin-bottom: 0.5rem; }
.team-invite-form button.primary { margin-top: 0.35rem; }

.wallet-balance-line { font-size: 1.35rem; margin: 0.75rem 0; }
.wallet-credit-actions { margin: 0.5rem 0; }
.wallet-ledger-scroll { max-height: min(55vh, 520px); overflow-y: auto; }

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

.reporting-filters { gap: 0.75rem; align-items: flex-end; margin-top: 0.75rem; }
.reporting-filters label { margin-bottom: 0; min-width: 8rem; }
.reporting-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.reporting-bars { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.5rem; }
.reporting-bar-row { display: grid; grid-template-columns: 5.5rem 1fr 2.5rem; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.reporting-bar-track { background: #f7f8fa; border-radius: 6px; height: 0.65rem; overflow: hidden; }
.reporting-bar-fill { background: var(--accent, #5b8def); height: 100%; border-radius: 6px; min-width: 2px; }
.reporting-table table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.reporting-table th, .reporting-table td { text-align: left; padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--border); }
.reporting-table th { color: var(--muted); font-weight: 500; }
.reporting-table .muted { color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.metric-value { font-size: 1.6rem; font-weight: 700; }

.check-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0.75rem 0;
  cursor: pointer;
}

.check-row.disabled { opacity: 0.55; cursor: default; }

.placeholder-code {
  background: #f7f8fa;
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--muted);
  margin: 0;
}

main { padding: 1rem 1.5rem 2rem 0; max-width: 1280px; }

header h1 { margin: 0 0 0.25rem; font-size: 1.45rem; }
header p { margin: 0 0 1.25rem; color: var(--muted); }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.session-grid { grid-template-columns: 1fr 1.2fr; }

.log-actions { gap: 0.5rem; flex-wrap: wrap; }

.full { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select, textarea {
  background: #f7f8fa;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

textarea { width: 100%; resize: vertical; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row.spread { justify-content: space-between; }
.actions { margin-top: 0.75rem; }

button {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
  background: #f0f1f3;
  color: var(--text);
}

button.primary { background: var(--accent); color: #fff; }
button.danger { background: var(--danger); color: #fff; }

/* Shared call actions in Live control and Session. */
button.call-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.call-action svg { width: 18px; height: 18px; flex-shrink: 0; }
button.call-action-stop { background: #dc2626; border-color: var(--danger); color: #fff; }
button.call-action-stop:hover:not(:disabled) { background: #b91c1c; border-color: #f87171; }
button.call-action-stop:active:not(:disabled) { background: #991b1b; }
button.call-action-copy { background: #f0f1f3; }
button.call-action-copy:hover:not(:disabled) { background: #e4e6e9; border-color: var(--muted); }
button.call-action-copy:active:not(:disabled) { background: #dce0e5; }
button.call-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--card);
}
button.call-action:disabled { opacity: 0.45; cursor: not-allowed; }
button.call-action[hidden] { display: none; }
.session-actions { gap: 0.75rem; }
.session-controls .hint { margin-top: 0.75rem; }
.session-controls .hint:empty { margin: 0; }

.browser-operations-header,
.browser-operations-end {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.browser-operations-header h2 { margin: 0; }
.browser-operations-header > div { flex: 1 1 20rem; }
.browser-operations-header .call-action { flex-shrink: 0; }
.browser-operations-end {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.browser-operations-description { flex: 1 1 24rem; }
.browser-operations-description h3 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.browser-operations-description .hint { max-width: 65ch; }
button.browser-operations-drain {
  background: rgb(239 68 68 / 10%);
  border-color: rgb(239 68 68 / 40%);
  color: #b42318;
  text-align: left;
}
button.browser-operations-drain:hover:not(:disabled) {
  background: rgb(239 68 68 / 18%);
  border-color: #f87171;
}
button.browser-operations-drain:active:not(:disabled) { background: rgb(239 68 68 / 25%); }
#browser-operations-output {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#browser-operations-output:empty { margin: 0; padding: 0; border: 0; }

@media (prefers-reduced-motion: reduce) {
  button.call-action { transition: none; }
}

.pill {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.pill.idle { background: #e1e4e8; }
.pill.run { background: var(--ok); color: #052e16; }

.meta { font-size: 0.8rem; color: var(--muted); }

.hint { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--muted); }

h2 { margin: 0 0 0.75rem; font-size: 1rem; }

#logs {
  max-height: 420px;
  overflow: auto;
  background: #f7f8fa;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.72rem;
  white-space: pre-wrap;
  margin: 0;
}

.transcript {
  max-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.9rem;
  max-width: 95%;
}

.bubble.user { align-self: flex-end; background: #eaf0f6; }
.bubble.agent { align-self: flex-start; background: #f0f1f3; }
.bubble .who { font-size: 0.7rem; color: var(--muted); margin-bottom: 0.2rem; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.checklist li:last-child { border-bottom: none; }
.check-ok { color: var(--ok); }
.check-fail { color: #f87171; }

.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.history-calls,
.history-detail {
  display: flex;
  flex-direction: column;
  height: min(72vh, 640px);
  min-height: min(72vh, 640px);
  max-height: min(72vh, 640px);
  margin-bottom: 0;
  overflow: hidden;
}

/* Conversation details stack below their header on a separate page. */
.history-detail {
  height: auto;
  min-height: 0;
  max-height: none;
  min-width: 0;
  overflow: visible;
}

.history-calls > .hint,
.history-detail-head,
.history-meta-bar,
.history-call-id,
.history-filters,
.history-pagination {
  flex-shrink: 0;
}

.history-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.history-filters label { margin-bottom: 0; }

.history-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.75rem 0; }
.history-list-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-bottom: 0.5rem;
}

.history-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
  margin-top: auto;
}
.history-pagination .hint { margin: 0; }

.history-item {
  text-align: left;
  background: #f0f1f3;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  width: 100%;
}
.history-item:hover, .history-item.active {
  border-color: var(--accent);
  background: #e9ebee;
}
.history-item .history-item-id {
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
  word-break: break-all;
}
.history-item .meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

.history-detail-head h2 { margin-bottom: 0; }
.history-detail-head { margin-bottom: 0.65rem; }

.history-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.history-meta-bar[hidden] { display: none !important; }

.history-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #f7f8fa;
  border: 1px solid var(--border);
  color: var(--muted);
}
.history-pill.accent { border-color: var(--accent); color: #374151; }
.history-pill.ok { border-color: var(--ok); color: #167044; }

.history-call-id {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  word-break: break-all;
}

.history-transcript-view {
  flex: 0 0 auto;
  height: min(40vh, 420px);
  min-height: 180px;
  margin-top: 0;
  padding: 0.75rem;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#history-transcript.transcript {
  max-height: none;
}

.history-transcript-view .history-empty {
  margin: 2rem auto;
  text-align: center;
  max-width: 18rem;
}

.history-transcript-view .bubble {
  max-width: min(92%, 28rem);
  line-height: 1.45;
}
.history-transcript-view .bubble .who {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.history-transcript-view .bubble .msg-time {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.35rem;
  opacity: 0.85;
}

.saved-agent-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  background: #f0f1f3;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
.saved-agent-item.active-runtime { border-color: var(--ok); }
.saved-agent-item .saved-agent-main { flex: 1; min-width: 0; width: 100%; }
.saved-agent-item .saved-agent-title { font-weight: 600; }
.saved-agent-item .saved-agent-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
  flex-wrap: wrap;
  width: 100%;
}
.saved-agent-item button {
  font-size: 0.8rem;
  padding: 0.35rem 0.55rem;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: 1rem;
  align-items: start;
}

.builder-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.builder-toolbar h2 { margin-bottom: 0.25rem; }
.toolbar-hint { margin-top: 0.2rem; max-width: 36rem; }
.builder-actions { margin-top: 0; justify-content: flex-end; }
.builder-toolbar .spread { align-items: flex-start; gap: 1rem; }

.identity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}
.identity-grid label { margin-bottom: 0; }

.builder-library {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.builder-library .history-list { margin-top: 0.85rem; }

#panel-prompt .card > label {
  margin-bottom: 0.35rem;
}
#panel-prompt textarea#first_message { min-height: 4.5rem; }
#panel-prompt textarea#system_prompt { min-height: 18rem; }

.steps ol { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.steps li { margin-bottom: 0.35rem; }

@media (max-width: 1100px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-library { position: static; max-height: none; }
  .history-layout { grid-template-columns: 1fr; }
  .history-calls,
  .history-detail {
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
  }
  .history-transcript-view {
    max-height: min(50vh, 420px);
  }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 0 1rem 2rem; }
  .session-grid { grid-template-columns: 1fr; }
  .builder-layout { grid-template-columns: 1fr; }
  .identity-grid { grid-template-columns: 1fr; }
  .builder-library { position: static; max-height: none; }
  .builder-actions { justify-content: flex-start; }
}

/* Entity extraction extends configuration and the existing transcript card. */
.entity-config { grid-column: 1 / -1; }
.entity-config h3 { margin: 1.2rem 0 0.65rem; }
.entity-config textarea { width: 100%; box-sizing: border-box; }
.entity-field-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 1fr) minmax(180px, 2fr) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.entity-field-row label { min-width: 0; }
.entity-field-row input, .entity-field-row textarea { width: 100%; box-sizing: border-box; }
.entity-llm-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.entity-config-error { color: #b42318; }
.history-entities {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-width: 0;
  margin-bottom: 0;
}
.history-entities[hidden] { display: none; }
.entity-details-head { align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.entity-details-head h3 { font-size: 1rem; margin: 0; }
.entity-table-scroll { overflow: auto; margin-top: 0.65rem; max-height: 24rem; flex: 0 0 auto; }
.history-entities > :not(.entity-table-scroll) { flex-shrink: 0; }
.entity-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.85rem; }
.entity-table th, .entity-table td { padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere; white-space: pre-wrap; }
.entity-table thead th:first-child { width: 30%; }
.entity-table thead th:last-child { width: 20%; }
.entity-table thead { color: var(--muted); }
.entity-confidence-note { font-size: 0.75rem; }
.entity-stale { color: #8a5800; font-size: 0.8rem; }
@media (max-width: 700px) {
  .entity-field-row { grid-template-columns: 1fr 1fr; }
  .entity-field-row label:nth-child(3) { grid-column: 1 / -1; }
  .entity-llm-settings { grid-template-columns: 1fr; }
  .entity-table { font-size: 0.78rem; }
  .entity-table th, .entity-table td { padding: 0.5rem 0.25rem; }
  .entity-table thead th:first-child { width: 28%; }
  .entity-table thead th:last-child { width: 27%; }
}

#telephony-setup { overflow-wrap: anywhere; }
#telephony-setup p { margin: 0.4rem 0; }

/* Shared light workspace. Presentation only: panel and role visibility are
   still owned by the existing application controllers. */
body { font-size: 14px; -webkit-font-smoothing: antialiased; }
.layout { grid-template-columns: 248px minmax(0, 1fr); }
.sidebar.card {
  margin: 0; padding: 26px 14px 16px; top: 0; height: 100vh;
  border: 0; border-right: 1px solid var(--border); border-radius: 0;
  background: #f1f2f4; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: 21px; letter-spacing: -0.6px; font-weight: 650; }
.brand-mark { width: 23px; height: 23px; }
.brand-sub { padding: 0 12px; margin: 4px 0 25px 33px; font-size: 12px; }
nav { gap: 3px; }
.nav { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 9px 12px; border-radius: 10px; font-size: 14px; flex-shrink: 0; }
.nav[hidden] { display: none; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav:hover { background: #e8eaed; }
.nav.active { background: #e1e4e8; border-color: transparent; color: #17181a; font-weight: 600; }
.nav-group { padding: 0 12px; margin: 22px 0 7px; font-size: 10px; font-weight: 650; letter-spacing: 1.1px; }
.sidebar-foot { padding: 20px 12px 8px; margin: 0; overflow-wrap: anywhere; line-height: 1.6; }
#btn-logout { margin-top: 4px; color: #a32b35; }
main { min-width: 0; max-width: none; padding: 0 34px 40px; }
.workspace-bar {
  height: 68px; margin: 0 -34px 30px; padding: 0 34px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.workspace-name { font-weight: 600; font-size: 14px; }
.workspace-tag { color: var(--muted); font-size: 12px; background: #f3f4f6; border-radius: 99px; padding: 5px 12px; }
main > header { margin-bottom: 26px; }
header h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.9px; margin-bottom: 7px; }
header p { font-size: 14px; margin-bottom: 0; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
h3 { font-weight: 600; }
.card { padding: 24px; border-radius: 16px; margin-bottom: 20px; }
.grid, .builder-layout, .history-layout, .team-grid { gap: 20px; }
.grid > *, .metrics > *, .team-grid > * { min-width: 0; }
.metrics { gap: 0; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 22px 4px; overflow: hidden; }
.metrics .metric { border: 0; border-radius: 0; border-right: 1px solid var(--border); padding: 4px 22px; margin: 0; background: transparent; }
.metrics .metric:last-child { border-right: 0; }
.metric-label { font-size: 12px; min-height: 36px; }
.metric-value { font-size: 30px; font-weight: 500; letter-spacing: -1px; overflow-wrap: anywhere; }
label { color: #525966; font-size: 13px; gap: 7px; margin-bottom: 16px; }
input, select, textarea { min-width: 0; max-width: 100%; padding: 10px 12px; border-color: #e0e3e7; border-radius: 9px; background: #f8f9fa; font-size: 14px; }
input:not([type=checkbox]):not([type=radio]), select { min-height: 41px; }
input[type=checkbox], input[type=radio] { accent-color: #25272b; }
textarea { line-height: 1.65; }
input::placeholder, textarea::placeholder { color: #818894; }
button { border: 1px solid transparent; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 500; line-height: 1.5; }
button:hover:not(:disabled) { background: #e4e6e9; }
button.primary:hover:not(:disabled) { background: #35373c; }
button.danger:hover:not(:disabled) { background: #a92525; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
a { color: #355d86; text-underline-offset: 3px; }
:where(button, input, select, textarea, a):focus-visible { outline: 2px solid #507ca7; outline-offset: 3px; }
button.call-action { border-radius: 999px; font-size: 13px; }
.hint, .meta { line-height: 1.65; }
.hint:empty { margin: 0; }
.pill.idle { color: #535c69; background: #eceef1; }
.pill.run { background: #e4f4ea; color: #17673d; }
.check-fail { color: #b42318; }
.team-row, .saved-agent-item { padding: 16px; border-radius: 12px; background: #fff; }
.saved-agent-item.active-runtime { border-color: #98c7aa; background: #f8fcf9; }
.saved-agent-item button { padding: 6px 10px; }
.history-item { padding: 13px; border-radius: 10px; background: #f8f9fa; }
.history-item:hover, .history-item.active { border-color: #b8bdc5; background: #eceef1; }
.history-pill { background: #f4f5f7; }
.bubble { padding: 12px 15px; border-radius: 12px; overflow-wrap: anywhere; }
#logs { color: #485361; padding: 16px; line-height: 1.7; }
.reporting-table { overflow-x: auto; }
.reporting-table th, .reporting-table td { padding: 13px 12px; }
.reporting-table th, .entity-table th { background: #f3f4f6; color: #697180; }
.reporting-table tbody tr:hover { background: #fafbfc; }
.wallet-ledger-scroll { overflow: auto; }
.steps ol { line-height: 1.9; }
.steps strong { color: #414751; font-weight: 500; }
.login-screen { background: #f3f4f6; }
.login-card { padding: 34px; border-radius: 20px; box-shadow: 0 12px 40px rgb(20 30 45 / 5%); }
.login-card h1 { font-size: 26px; letter-spacing: -0.7px; }
.login-card button.primary { min-height: 42px; }
@media (min-width: 1600px) {
  main { padding-left: 48px; padding-right: 48px; }
  .workspace-bar { margin-left: -48px; margin-right: -48px; padding: 0 48px; }
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 216px minmax(0, 1fr); }
  main { padding-left: 24px; padding-right: 24px; }
  .workspace-bar { margin-left: -24px; margin-right: -24px; padding: 0 24px; }
  .metrics { gap: 20px 0; }
  .metrics .metric { border-right: 0; }
  .session-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar.card { height: auto; position: static; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-sub { margin-bottom: 16px; }
  .nav-tree { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .nav-tree .nav-group { display: none; }
  .nav-tree .nav { white-space: nowrap; }
  .sidebar-foot { padding: 8px 12px 0; }
  #btn-logout { align-self: flex-start; }
  main { padding: 0 16px 28px; }
  .workspace-bar { height: 56px; padding: 0 16px; margin: 0 -16px 24px; }
  .card { padding: 18px; }
  header h1 { font-size: 25px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 26px; }
  .history-filters { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* History pages share the Studio shell, with the compact call-review layout. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#panel-history, #panel-history-detail { --history-muted: var(--muted); --history-line: var(--border); color: var(--text); }
#panel-history .card, #panel-history-detail .card { padding: 20px; border: 1px solid var(--history-line); border-radius: 10px; box-shadow: none; }
#panel-history button, #panel-history-detail button { border-radius: 10px; font-size: 12px; font-weight: 500; padding: 9px 13px; background: #f4f5f7; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#panel-history button:focus-visible, #panel-history-detail button:focus-visible, .history-conversation-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#panel-history h2, #panel-history-detail h2 { font-size: 21px; line-height: 1.35; font-weight: 700; letter-spacing: -0.5px; margin: 0; }
#panel-history .hint, #panel-history-detail .hint { color: var(--history-muted); }
#panel-history .history-calls { height: auto; min-height: 0; max-height: none; overflow: visible; }
.history-list-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.history-list-heading .hint { font-size: 12px; margin: 5px 0 0; }
.history-search { position: relative; display: block; width: 54%; margin: 0; }
.history-search svg { position: absolute; width: 17px; height: 17px; left: 12px; top: 13px; color: var(--history-muted); }
#panel-history input, #panel-history select { background: #fff; border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 12px; min-height: 40px; width: 100%; }
#panel-history .history-search input { padding-left: 37px; }
#panel-history input::placeholder { color: var(--muted); }
#panel-history .history-filters { display: grid; grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1.1fr) minmax(140px, 1.25fr) auto; gap: 16px; align-items: start; margin: 0 0 24px; }
#panel-history .history-filters > button { min-height: 40px; margin-left: 8px; }
#btn-refresh-history > span { font-size: 20px; line-height: 16px; }
.history-date-filter { position: relative; font-size: 12px; color: var(--history-muted); min-width: 0; }
.history-date-filter summary { min-height: 40px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 7px; padding: 9px 12px; cursor: pointer; list-style: none; }
.history-date-filter summary::-webkit-details-marker { display: none; }
.history-date-filter summary svg { width: 17px; height: 17px; color: var(--text); flex-shrink: 0; }
#history-date-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-date-popover { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; min-width: 240px; padding: 16px; border: 1px solid var(--history-line); border-radius: 10px; background: var(--card); box-shadow: 0 8px 28px #14284918; }
.history-date-popover label { display: block; margin-bottom: 10px; }
.history-table-scroll { overflow-x: auto; border: 1px solid var(--history-line); border-radius: 8px; }
.history-table { border-collapse: collapse; width: 100%; font-size: 12px; text-align: left; white-space: nowrap; }
.history-table th { color: var(--muted); font-size: 11px; font-weight: 600; background: #f8f9fb; padding: 12px 10px; }
.history-table td { border-top: 1px solid var(--history-line); padding: 17px 10px; }
#panel-history #btn-history-sort { padding: 0; border: 0; background: transparent; color: inherit; font-size: inherit; font-weight: inherit; }
.history-table .history-item { background: transparent; border: 0; border-radius: 0; padding: 0; cursor: default; }
.history-table .history-item:hover, .history-table .history-item.active { background: #f0f1f3; }
.history-table .history-item:first-child { background: #f0f1f3; }
.history-date { font-variant-numeric: tabular-nums; }
.history-status, .history-channel { display: inline-flex; align-items: center; white-space: nowrap; padding: 4px 7px; border-radius: 6px; font-size: 11px; font-weight: 500; }
#history-call-status[hidden] { display: none; }
.history-status.completed { color: #008653; background: #e1f9ee; }
.history-status.error { color: #b42332; background: #fff0f1; }
.history-status.pending { color: #8a6200; background: #fff6d9; }
.history-channel { background: #f0f1f3; color: var(--text); }
.history-conversation-link { color: var(--text); text-decoration: none; font-size: 11px; }
.history-conversation-link:hover { text-decoration: underline; }
.history-row-chevron { float: right; margin-left: 15px; color: var(--muted); font-size: 18px; line-height: 18px; }
.history-table-message { text-align: center; padding: 32px !important; color: var(--history-muted); }
#panel-history .history-pagination { margin-top: 20px; padding: 0; border: 0; gap: 16px; }
.history-page-buttons, #history-page-numbers { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 5px; }
.history-page-buttons { flex: none; }
#panel-history #history-page-numbers button { border: 1px solid var(--border); background: #fff; min-width: 34px; padding: 8px; color: var(--muted); }
#panel-history #history-page-numbers button.active { background: var(--accent); border-color: var(--accent); color: var(--card); box-shadow: none; }
.history-page-gap { padding: 0 5px; color: var(--history-muted); }
#panel-history .history-pagination .hint { font-size: 12px; }
#panel-history-detail .history-layout { gap: 12px; }
#panel-history-detail .history-layout > .card { margin: 0; }
.history-breadcrumb { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--history-muted); font-size: 11px; margin-bottom: 24px; }
#panel-history-detail .history-breadcrumb button { background: transparent; color: var(--history-muted); padding: 0; border-radius: 0; font-size: inherit; }
#history-breadcrumb-id { overflow-wrap: anywhere; min-width: 0; }
#panel-history-detail .history-detail-head { margin-bottom: 18px; gap: 16px; align-items: center; }
.history-id-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 7px; }
#panel-history-detail .history-call-id { font-family: inherit; font-size: 12px; margin: 0; }
#history-call-status { border: 1px solid #72cfaa; background: #f0fff7; }
#history-call-status.error { border-color: var(--danger); background: #fff0f1; }
#panel-history-detail #btn-back-history { flex-shrink: 0; }
.history-summary-grid { display: grid; grid-template-columns: 1.65fr 0.9fr 1fr 0.9fr 0.8fr 0.8fr; gap: 18px; padding: 14px 12px; border: 1px solid var(--history-line); border-radius: 8px; background: #fafbfd; font-size: 12px; }
.history-summary-grid[hidden] { display: none; }
.history-summary-grid > div { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; min-width: 0; }
.history-summary-grid span { color: var(--muted); font-weight: 600; font-size: 11px; }
.history-summary-grid strong { font-weight: 400; color: var(--text); overflow-wrap: anywhere; }
.history-summary-grid .history-channel { color: var(--text); font-size: 10px; }
#panel-history-detail #btn-copy-history-transcript svg { width: 15px; height: 15px; }
#panel-history-detail .history-meta-bar { gap: 6px; margin-bottom: 16px; }
#panel-history-detail .history-pill { border: 1px solid transparent; border-radius: 999px; padding: 5px 9px; font-size: 10px; color: var(--muted); background: #f4f6f9; }
#panel-history-detail .history-pill.accent { border-color: var(--muted); color: var(--text); background: #fff; }
#panel-history-detail .history-pill.ok { border-color: #68c8a0; color: #008653; background: #f5fffa; }
#panel-history-detail .history-transcript-view { display: flex; flex-direction: column; gap: 12px; height: min(48vh, 400px); min-height: 280px; padding: 10px; background: #fff; border-color: var(--history-line); border-radius: 10px; }
#panel-history-detail .history-transcript-view .bubble { flex-shrink: 0; max-width: 74%; border-radius: 12px; padding: 14px 17px; font-size: 14px; line-height: 1.65; }
#panel-history-detail .bubble.user { background: #eaf0f6; }
#panel-history-detail .bubble.agent { background: #f5f6f8; }
#panel-history-detail .bubble .who { font-size: 10px; color: var(--muted); }
#panel-history-detail .bubble .msg-time { font-size: 10px; color: var(--muted); }
#panel-history-detail .entity-details-head h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
#panel-history-detail .entity-details-head > .history-pill { background: #f0f1f3; color: var(--muted); padding: 6px 13px; font-size: 12px; }
#panel-history-detail .entity-table-scroll { border: 1px solid var(--history-line); border-radius: 7px; margin-top: 15px; max-height: none; }
#panel-history-detail .entity-table { font-size: 12px; line-height: 1.35; }
#panel-history-detail .entity-table th, #panel-history-detail .entity-table td { padding: 7px 10px; border-bottom-color: var(--history-line); }
#panel-history-detail .entity-table thead th { background: #f5f6f8; color: var(--muted); }
#panel-history-detail .entity-table tbody th { background: transparent; color: var(--muted); font-weight: 600; }
#panel-history-detail .entity-table thead th:first-child { width: 38%; }
#panel-history-detail .entity-confidence-note { margin-bottom: 0; font-size: 10px; }
[data-theme="dark"] #panel-history, [data-theme="dark"] #panel-history-detail { --history-line: #2a3747; --history-muted: #9aa8ba; color: var(--text); }
[data-theme="dark"] #panel-history input, [data-theme="dark"] #panel-history select,
[data-theme="dark"] .history-date-filter summary { background: #0e1620; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .history-table th, [data-theme="dark"] .history-summary-grid { background: #1a2533; color: var(--muted); }
[data-theme="dark"] .history-table .history-item:first-child, [data-theme="dark"] .history-table .history-item:hover, [data-theme="dark"] .history-table .history-item.active { background: #262b33; }
[data-theme="dark"] #panel-history-detail .history-transcript-view { background: #0e1620; }
[data-theme="dark"] #panel-history-detail .bubble.agent { background: #253041; }
[data-theme="dark"] #panel-history-detail .bubble.user { background: #262b33; }
[data-theme="dark"] .history-channel { background: #262b33; color: var(--text); }
[data-theme="dark"] .history-conversation-link { color: var(--text); }
[data-theme="dark"] #panel-history-detail .entity-table tbody th { color: #a3b5d0; }
[data-theme="dark"] #panel-history-detail .entity-table thead th { background: #1a2533; color: #a3b5d0; }
[data-theme="dark"] #panel-history button, [data-theme="dark"] #panel-history-detail button,
[data-theme="dark"] #panel-history #history-page-numbers button { background: #213044; color: var(--text); border-color: var(--border); }
[data-theme="dark"] #panel-history #history-page-numbers button.active { background: var(--accent); color: var(--card); }
@media (max-width: 1050px) {
  .history-list-heading { flex-wrap: wrap; gap: 16px; }
  .history-search { width: 100%; }
  #panel-history .history-filters { grid-template-columns: 1fr 1fr; gap: 10px; }
  #panel-history .history-filters > button { margin: 0; }
  .history-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  #panel-history .card, #panel-history-detail .card { padding: 14px; }
  #panel-history-detail .history-detail-head { flex-wrap: wrap; }
  #panel-history-detail .history-transcript-view .bubble { max-width: 90%; font-size: 13px; }
  .history-summary-grid { gap: 14px; font-size: 11px; }
  #panel-history-detail .entity-details-head h3 { font-size: 17px; }
}
.history-table { table-layout: fixed; min-width: 720px; font-size: 11px; }
.history-table th, .history-table td { padding-left: 8px; padding-right: 8px; }
.history-table td { padding-top: 13px; padding-bottom: 13px; }
.history-table th:nth-child(1) { width: 4%; }
.history-table th:nth-child(2) { width: 18%; }
.history-table th:nth-child(3) { width: 10%; }
.history-table th:nth-child(4) { width: 13%; }
.history-table th:nth-child(5) { width: 11%; }
.history-table th:nth-child(6) { width: 10%; }
.history-table th:nth-child(7) { width: 34%; }
.history-table td { overflow: hidden; text-overflow: ellipsis; }
.history-table .history-status, .history-table .history-channel { font-size: 10px; padding: 4px 6px; }
.history-conversation-link { display: inline-block; max-width: calc(100% - 18px); overflow: hidden; text-overflow: ellipsis; vertical-align: middle; font-size: 10px; }
.history-row-chevron { margin-left: 6px; }
