:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #dce1e8;
  --line-soft: #edf0f4;
  --text: #17212b;
  --muted: #657181;
  --accent: #087f73;
  --accent-strong: #05685f;
  --accent-soft: #e8f7f4;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #9a6700;
  --warning-soft: #fff8e6;
  --positive: #067647;
  --positive-soft: #eaf8f0;
  --shadow: 0 12px 36px rgb(15 23 42 / 10%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
tr[role="button"] {
  outline-offset: 2px;
}

.shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.top-actions,
.panel-head,
.dialog-head,
.section-title,
.error-list article > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 18px;
}

.top-actions {
  justify-content: flex-end;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 17px;
}

h4 {
  font-size: 13px;
}

.topbar p,
.panel-head p,
.panel-head span,
.dialog-head span,
label > span,
.section-title > span,
.detail-meta span,
.analysis-summary span,
.metrics span,
td small,
.empty-state span,
.empty-card span {
  color: var(--muted);
}

.topbar p,
.panel-head p {
  margin-top: 5px;
}

.panel,
.metrics article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head.compact {
  align-items: flex-start;
}

.toolbar,
.report-filters {
  display: grid;
  gap: 10px;
}

.launch-toolbar {
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  align-items: end;
  padding: 14px 16px 16px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label > span,
.filter-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select-button {
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  text-align: left;
}

.multi-select-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-button i {
  color: var(--muted);
  font-style: normal;
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 20;
  display: grid;
  width: max(100%, 250px);
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.multi-select-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  cursor: pointer;
}

.multi-select-option:hover {
  background: #f1faf8;
}

.multi-select-option + .multi-select-option {
  border-top: 1px solid var(--line-soft);
}

.multi-select-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.multi-select-option span {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.multi-select-empty {
  padding: 12px;
  color: var(--muted);
}

input,
select,
button,
.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

input,
select {
  width: 100%;
  padding: 0 10px;
}

button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.secondary-button:hover,
input:hover,
select:hover {
  border-color: #abb5c2;
}

button:focus-visible,
.secondary-button:focus-visible,
input:focus-visible,
select:focus-visible,
tr[role="button"]:focus-visible {
  outline: 2px solid #3caaa0;
}

.primary {
  min-width: 184px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 21px;
  line-height: 1;
}

.text-button {
  min-height: auto;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #acd8d2;
  border-radius: 8px;
  background: var(--accent-soft);
}

.notice.error {
  border-color: #efb2ab;
  background: var(--danger-soft);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.metrics article {
  display: grid;
  gap: 7px;
  padding: 15px 16px;
}

.metrics strong {
  font-size: 25px;
  line-height: 1;
}

.report-head > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.report-filters {
  grid-template-columns: 1.6fr repeat(5, minmax(135px, 1fr));
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.filter-search {
  grid-column: span 2;
}

.sort-control {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
}

.sort-control button {
  padding: 0;
  font-size: 18px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.active-filters span,
.mini-tags span,
.detail-tags span,
.attention-badge,
.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 12px;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafbfc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

th.sortable {
  padding: 0;
}

th.sortable button {
  width: 100%;
  min-height: 43px;
  justify-content: flex-start;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

th.sortable button:hover {
  background: #f1f4f7;
}

.sort-indicator {
  min-width: 12px;
  color: var(--accent);
  font-size: 15px;
}

tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

tbody tr:hover,
tbody tr:focus-visible {
  background: #f1faf8;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td strong,
td .primary-value,
td small {
  display: block;
}

.deal-cell-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.call-page-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  color: var(--accent);
  font-size: 16px;
  text-decoration: none;
}

.call-page-link:hover {
  background: var(--accent-soft);
}

.pipeline-name {
  display: inline-block;
  max-width: 180px;
  font-weight: 650;
}

td small {
  margin-top: 4px;
  line-height: 1.35;
}

.numeric {
  text-align: right;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.mini-tags span {
  min-height: 20px;
  padding: 2px 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
}

.status,
.rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status.completed,
.rating.high {
  background: var(--positive-soft);
  color: var(--positive);
}

.status.failed,
.status.dead_letter,
.rating.low {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.processing,
.status.analyzed,
.rating.medium {
  background: var(--warning-soft);
  color: var(--warning);
}

.status.waiting_recording,
.status.retry,
.status.pending,
.status.queued {
  background: #eef4ff;
  color: #3452a5;
}

.rating {
  min-width: 40px;
  font-size: 13px;
}

.rating.empty {
  color: var(--muted);
}

.empty-state,
.empty-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 38px 16px;
  text-align: center;
}

dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(15 23 42 / 48%);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog-head > div {
  min-width: 0;
}

.dialog-head h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-head span {
  display: block;
  margin-top: 4px;
}

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

.standalone-call {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.standalone-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.standalone-topbar h1 {
  margin-top: 10px;
}

.standalone-topbar p {
  margin-top: 5px;
  color: var(--muted);
}

.back-link {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.standalone-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.standalone-card .detail {
  max-height: none;
  overflow: visible;
}

.detail {
  display: grid;
  gap: 0;
  max-height: calc(100vh - 98px);
  overflow: auto;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 18px;
  background: #fafbfc;
}

.detail-meta > div:not(.detail-actions),
.analysis-summary > div {
  display: grid;
  align-content: start;
  gap: 5px;
}

.detail-meta span,
.analysis-summary span {
  font-size: 12px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  grid-column: span 2;
}

.detail-section {
  padding: 18px;
  border-top: 1px solid var(--line-soft);
}

.section-title {
  align-items: baseline;
  margin-bottom: 13px;
}

.attention-badge {
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 700;
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.compact-summary {
  grid-template-columns: repeat(4, 1fr);
}

.tag-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.tag-groups h4 {
  margin-bottom: 8px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-tags.error span {
  background: var(--danger-soft);
  color: var(--danger);
}

.detail-tags.risk span {
  background: var(--warning-soft);
  color: var(--warning);
}

.narrative-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.narrative,
.callout,
.error-list article {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
}

.narrative h4,
.callout strong {
  display: block;
  margin-bottom: 7px;
}

.narrative p,
.callout p,
.error-list p,
.phrase p {
  line-height: 1.55;
}

.narrative.positive {
  border-left-color: var(--positive);
}

.narrative.warning,
.callout.warning {
  border-left-color: #e7a61a;
}

.narrative.accent {
  border-left-color: var(--accent);
}

.narrative.neutral,
.callout.neutral {
  border-left-color: #8b98a7;
}

.callout {
  margin-top: 14px;
}

.error-list {
  display: grid;
  gap: 10px;
}

.error-list article {
  border-left-color: var(--danger);
}

.error-list article > div {
  justify-content: flex-start;
}

.error-list p {
  margin-top: 8px;
}

.severity.S1 {
  background: var(--warning-soft);
  color: var(--warning);
}

.severity.S2,
.severity.S3 {
  background: var(--danger-soft);
  color: var(--danger);
}

.score-list {
  display: grid;
  gap: 10px;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 2fr) 48px;
  align-items: center;
  gap: 12px;
}

.score-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

.score-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.score-explanations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.score-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.score-card.not-applicable {
  background: #f8fafc;
  color: var(--muted);
}

.score-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-card-head span {
  flex: none;
  font-weight: 700;
  color: var(--accent);
}

.score-card.not-applicable .score-card-head span {
  color: var(--muted);
}

.score-card p,
.score-card small {
  margin: 0;
  line-height: 1.45;
}

.transcript {
  display: grid;
  gap: 10px;
}

.phrase {
  width: min(82%, 780px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  background: #f8fafc;
}

.phrase.manager {
  justify-self: end;
  border-color: #bfe3de;
  background: var(--accent-soft);
}

.phrase > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.phrase time {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1240px) {
  .launch-toolbar,
  .report-filters {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-search {
    grid-column: span 1;
  }
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 1560px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .launch-toolbar,
  .report-filters,
  .metrics,
  .detail-meta,
  .analysis-summary,
  .compact-summary,
  .tag-groups,
  .narrative-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 580px) {
  .topbar,
  .panel-head.report-head,
  .standalone-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .standalone-call {
    width: min(100vw - 20px, 1120px);
    padding-top: 14px;
  }

  .dialog-actions .secondary-button {
    display: none;
  }

  .launch-toolbar,
  .report-filters,
  .metrics,
  .detail-meta,
  .analysis-summary,
  .compact-summary,
  .tag-groups,
  .narrative-grid,
  .score-explanations {
    grid-template-columns: 1fr;
  }

  .primary {
    width: 100%;
  }

  .detail-actions {
    grid-column: auto;
  }

  .score-row {
    grid-template-columns: 1fr 42px;
  }

  .score-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .phrase {
    width: 96%;
  }
}
