:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-muted: #f0f1f4;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --soft: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.07);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --purple: #af52de;
  --call-grid: minmax(240px, 1.45fr) minmax(128px, 0.82fr) minmax(148px, 0.9fr) minmax(70px, 0.42fr) minmax(116px, 0.58fr) minmax(118px, 0.5fr);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f5f5f8;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(0, 122, 255, 0.105), rgba(0, 122, 255, 0) 30rem),
    radial-gradient(circle at 72% 0%, rgba(175, 82, 222, 0.06), rgba(175, 82, 222, 0) 28rem),
    linear-gradient(180deg, #ffffff 0%, #f6f8fc 42%, #f2f3f7 100%);
  background-attachment: fixed, fixed, fixed;
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-size: 100% 100vh, 100% 100vh, 100% 100%;
  color: var(--text);
}

button,
input,
select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font: inherit;
  line-height: normal;
  -webkit-font-smoothing: antialiased;
}

button {
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

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

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 18px;
  min-height: 100vh;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

#search-view.is-active,
#login-view.is-active {
  display: grid;
  min-height: calc(100vh - 56px);
  place-items: center;
}

.search-panel {
  display: grid;
  gap: 22px;
  width: min(520px, 100%);
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.search-copy {
  justify-items: center;
  display: grid;
  gap: 4px;
  text-align: center;
}

.eyebrow {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.search-copy h1 {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
}

.search-copy p:not(.eyebrow) {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.search-controls {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(330px, 100%);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.035);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  box-shadow: none;
}

.segmented button.is-selected {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.search-controls > .btn-primary {
  width: min(330px, 100%);
}

.btn-primary {
  border-color: rgba(0, 0, 0, 0.86);
  background: #1d1d1f;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.btn-primary:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.search-panel .status {
  text-align: center;
}

.status.is-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: var(--text);
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.status.error {
  color: var(--red);
}

.workspace-head,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.workspace-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workspace-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  color: var(--muted);
}

.workspace-summary strong {
  color: var(--text);
  font-size: 18px;
}

.table-card {
  display: grid;
  gap: 16px;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) repeat(4, minmax(140px, 1fr)) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.045);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.grouped-rows {
  display: grid;
  gap: 18px;
}

.day-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.055);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.day-toggle {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.58);
  text-align: left;
}

.day-toggle:hover {
  background: rgba(255, 255, 255, 0.86);
  transform: none;
}

.day-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
}

.day-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.day-chevron {
  width: 9px;
  height: 9px;
  margin-left: 2px;
  border-right: 1.5px solid var(--soft);
  border-bottom: 1.5px solid var(--soft);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease;
}

.day-card.is-collapsed .day-chevron {
  transform: rotate(-45deg);
}

.day-card.is-collapsed .day-list {
  display: none;
}

.day-list {
  display: grid;
}

.call-row {
  display: grid;
  grid-template-columns: var(--call-grid);
  gap: 18px;
  align-items: center;
  min-height: 76px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  transition: background 160ms ease;
}

.call-row:first-child {
  border-top: 0;
}

.call-row:hover {
  background: rgba(255, 255, 255, 0.58);
}

.call-row.is-reviewed {
  background: linear-gradient(90deg, rgba(52, 199, 89, 0.1), rgba(255, 255, 255, 0) 28%);
}

.lead-cell,
.duration-cell,
.date-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.setter-cell,
.duration-cell,
.date-cell {
  color: var(--text);
  min-width: 0;
}

.status-cell,
.action-cell {
  min-width: 0;
}

.lead-name {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.duration-cell .subtle {
  font-weight: 400;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  width: fit-content;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.pill.done {
  background: rgba(52, 199, 89, 0.14);
  color: #1f7a3a;
}

.pill.open {
  background: rgba(255, 159, 10, 0.15);
  color: #9a6400;
}

.close-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.035);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.close-link:hover {
  background: rgba(0, 0, 0, 0.06);
}

.test-pill {
  margin-top: 1px;
}

.action-cell {
  display: flex;
  justify-content: flex-end;
}

.row-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 104px;
  min-height: 34px;
  border-color: rgba(0, 0, 0, 0.84);
  border-radius: 999px;
  background: #1d1d1f;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.11);
}

.row-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.13);
}

.row-button.is-reviewed {
  border-color: rgba(52, 199, 89, 0.28);
  background: rgba(52, 199, 89, 0.12);
  color: #177338;
  box-shadow: none;
}

.row-button.is-reviewed:hover {
  background: rgba(52, 199, 89, 0.18);
}

.row-button.is-analyzing,
.row-button.is-analyzing:disabled {
  min-width: 104px;
  padding: 0 13px;
  border-color: rgba(0, 122, 255, 0.28);
  background: #007aff;
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 122, 255, 0.22);
  cursor: default;
  opacity: 1;
}

.row-button.is-analyzing:hover {
  transform: none;
  box-shadow: 0 8px 18px rgba(0, 122, 255, 0.22);
}

.button-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.analysis-flow {
  display: grid;
  gap: 24px;
  width: min(720px, 100%);
  margin: 10vh auto 0;
}

.flow-card {
  display: grid;
  gap: 26px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flow-card h2 {
  font-size: 30px;
}

.steps {
  display: grid;
  gap: 12px;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.step span {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid var(--border);
}

.step.is-active {
  color: var(--text);
}

.step.is-active span {
  border-color: var(--blue);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

.step.is-done {
  color: var(--text);
}

.step.is-done span {
  display: grid;
  place-items: center;
  border-color: var(--green);
  background: var(--green);
}

.step.is-done span::after {
  content: "";
  width: 8px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-meta {
  margin-bottom: 16px;
}

.call-summary {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 2fr);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.call-summary-main {
  display: grid;
  gap: 5px;
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}

.call-summary-main span,
.call-summary-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.call-summary-main strong {
  font-size: 22px;
  line-height: 1.15;
}

.call-summary-main p {
  color: var(--muted);
  font-size: 13px;
}

.summary-close-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 30px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.summary-close-link:hover {
  background: rgba(0, 0, 0, 0.07);
}

.call-summary-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0;
}

.call-summary-facts div {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  padding: 16px 18px;
  border-left: 1px solid var(--border);
}

.call-summary-facts div:first-child {
  border-left: 0;
}

.call-summary-facts dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.88fr);
  gap: 18px;
  align-items: start;
}

.transcript-panel,
.analysis-panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.transcript-panel {
  padding: 0;
}

.transcript-panel h2 {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.transcript-content {
  display: grid;
  gap: 0;
  padding: 4px 0;
}

.transcript-turn {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.055);
}

.transcript-turn:first-child {
  border-top: 0;
}

.transcript-turn span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: start;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.transcript-turn span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--soft);
}

.transcript-turn.is-setter {
  background: rgba(0, 0, 0, 0.018);
}

.transcript-turn.is-setter span {
  color: var(--text);
}

.transcript-turn.is-setter span::before {
  background: var(--text);
}

.transcript-turn p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.analysis-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.review-summary {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-solid);
}

.score-block {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
}

.score-block span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-block strong {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  font-size: 32px;
  line-height: 1;
  white-space: nowrap;
}

.score-block small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.review-copy {
  display: grid;
  gap: 8px;
}

.review-copy h2 {
  font-size: 21px;
  line-height: 1.15;
}

.analysis-section {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-solid);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-heading span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
}

.analysis-section.good .section-heading span {
  background: var(--green);
}

.analysis-section.warn .section-heading span {
  background: var(--orange);
}

.analysis-section.bad .section-heading span {
  background: var(--red);
}

.analysis-section.info .section-heading span {
  background: var(--soft);
}

.analysis-section h3 {
  font-size: 14px;
}

.analysis-section p,
.analysis-section li {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.analysis-section ul {
  margin: 0;
  padding-left: 18px;
}

.analysis-section li::marker {
  color: var(--soft);
}

.objection-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.objection-facts p {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-muted);
}

.objection-facts strong {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 44px 18px;
  color: var(--muted);
  text-align: center;
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast-card {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  pointer-events: auto;
}

.toast-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toast-card strong {
  padding-right: 26px;
  font-size: 15px;
}

.toast-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.toast-open {
  width: fit-content;
  min-height: 32px;
  margin-top: 4px;
  border-color: rgba(0, 0, 0, 0.84);
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
}

.toast-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.045);
}

.toast-close::before {
  content: "";
  width: 10px;
  height: 10px;
  background:
    linear-gradient(45deg, transparent 44%, var(--muted) 45%, var(--muted) 55%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--muted) 45%, var(--muted) 55%, transparent 56%);
}

.toast-card.is-error {
  border-color: rgba(255, 59, 48, 0.22);
}

@media (max-width: 920px) {
  .app-shell {
    padding: 12px;
  }

  .search-panel {
    padding: 20px;
  }

  .search-controls,
  .result-meta,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .table-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }

  #clear-filters {
    grid-column: 1 / -1;
  }

  .workspace-head,
  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workspace-summary {
    justify-content: space-between;
  }

  .call-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "lead action"
      "status action"
      "setter date"
      "duration date";
    gap: 9px 14px;
    min-height: 0;
    padding: 15px;
  }

  .lead-cell {
    grid-area: lead;
  }

  .status-cell {
    grid-area: status;
  }

  .setter-cell {
    grid-area: setter;
    color: var(--muted);
    font-size: 13px;
  }

  .duration-cell {
    grid-area: duration;
    font-weight: 700;
  }

  .date-cell {
    grid-area: date;
    justify-items: end;
    text-align: right;
  }

  .action-cell {
    grid-area: action;
    align-self: start;
  }
}

@media (max-width: 640px) {
  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .table-toolbar input[type="search"],
  #clear-filters {
    grid-column: auto;
  }

  .workspace-summary {
    display: grid;
    gap: 4px;
  }

  .day-toggle {
    padding: 0 14px;
  }

  .call-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "lead"
      "status"
      "setter"
      "duration"
      "date"
      "action";
  }

  .date-cell {
    justify-items: start;
    text-align: left;
  }

  .action-cell,
  .row-button {
    width: 100%;
  }

  .toast-root {
    right: 12px;
    bottom: 12px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .result-head,
  .workspace-head,
  .table-toolbar,
  .btn-primary,
  .btn-ghost {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .view:not(.is-active) {
    display: none !important;
  }

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

  .transcript-panel,
  .analysis-panel,
  .meta-card,
  .analysis-section {
    box-shadow: none;
    break-inside: avoid;
  }
}
