:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f5f8;
  --surface-3: #eaf0f6;
  --text: #18202a;
  --muted: #627084;
  --line: #d9e0e9;
  --line-strong: #b8c4d2;
  --blue: #2457d6;
  --green: #158053;
  --amber: #9a6107;
  --red: #bd2d2d;
  --purple: #6a4bb8;
  --shadow: 0 12px 34px rgba(20, 30, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-weight: 650;
}

button:hover {
  border-color: var(--blue);
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

button.secondary {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.top-actions-wrap {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions a {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  font-weight: 650;
}

.top-actions a:hover {
  border-color: var(--blue);
  text-decoration: none;
}

.sync-line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

#apiStatus {
  min-width: 112px;
  text-align: right;
}

#apiStatus.ok {
  color: var(--green);
}

#apiStatus.bad {
  color: var(--red);
}

main {
  padding: 22px 28px 44px;
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(420px, 1.25fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 14px;
}

.summary-copy,
.funnel-panel,
.side-panel,
.table-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-copy {
  padding: 20px;
}

.summary-copy p {
  color: var(--muted);
  margin-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-head.compact {
  padding: 14px 16px 10px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.funnel-bars {
  display: grid;
  gap: 7px;
  padding: 6px 16px 16px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 132px minmax(120px, 1fr) 34px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 30px;
  border-color: transparent;
  padding: 4px 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.funnel-row:hover {
  border-color: transparent;
  color: var(--blue);
}

.funnel-row.active .funnel-label,
.funnel-row.active strong {
  color: var(--blue);
}

.funnel-row.active .funnel-track {
  outline: 1px solid var(--blue);
}

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

.funnel-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.funnel-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(104px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.kpi {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px;
}

.kpi strong {
  display: block;
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.kpi small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

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

.search-wrap {
  width: min(420px, 100%);
}

.search-wrap label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.search-wrap input,
select,
textarea,
.form-grid input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.search-wrap input,
select,
.form-grid input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tab {
  min-width: 76px;
  border-color: var(--line);
  color: var(--muted);
}

.tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #f2f6ff;
}

.content-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 96px;
  padding: 18px;
}

.side-panel p {
  color: var(--muted);
  margin-bottom: 16px;
}

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

.priority-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.priority-item strong {
  display: block;
}

.priority-item small {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.priority-item button {
  width: fit-content;
  margin-top: 4px;
}

.table-actions {
  display: flex;
  gap: 8px;
}

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

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

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

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

td {
  background: var(--surface);
}

tbody tr:hover td {
  background: #fbfcfe;
}

.meeting-main {
  max-width: 320px;
}

.meeting-title {
  display: block;
  margin-bottom: 5px;
  font-weight: 750;
}

.meeting-meta,
.email-list,
.company-line,
.muted,
.row-status {
  color: var(--muted);
}

.company-line {
  margin-top: 4px;
}

.email-list {
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.pill.ok {
  background: #e8f6ef;
  color: var(--green);
}

.pill.warn {
  background: #fff4df;
  color: var(--amber);
}

.pill.bad {
  background: #fff0f0;
  color: var(--red);
}

.pill.source {
  background: #f1efff;
  color: var(--purple);
}

.pill.neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.row-status {
  margin-top: 8px;
  font-size: 13px;
}

.link-stack {
  display: grid;
  gap: 7px;
  min-width: 136px;
}

.link-stack a {
  width: fit-content;
  font-weight: 650;
}

.deal-list,
.source-list {
  display: grid;
  gap: 7px;
  min-width: 190px;
  max-width: 320px;
}

.deal-list a,
.source-list span {
  display: block;
  overflow-wrap: anywhere;
}

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

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 24, 36, 0.28);
}

.editor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(620px, 100vw);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -18px 0 40px rgba(20, 30, 44, 0.12);
  transform: translateX(100%);
  transition: transform 160ms ease;
}

.editor-drawer.open {
  transform: translateX(0);
}

.editor-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.editor-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
}

.raw-details {
  margin: 0 20px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.raw-details summary {
  cursor: pointer;
  padding: 11px 12px;
  color: var(--muted);
  font-weight: 750;
}

.raw-details pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 0 12px 12px;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 12px;
}

.editor-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 1080px) {
  .summary-band,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar,
  .controls,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions-wrap {
    justify-items: stretch;
  }

  .top-actions,
  .sync-line,
  .tabs {
    justify-content: flex-start;
  }

  main,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .table-wrap {
    max-height: none;
  }

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