:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #fafbfc;
  --ink: #111827;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d9dee7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #10b981;
  --green-soft: #d1fae5;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button,
.primary-link {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: var(--shadow-sm);
}

button:hover,
.primary-link:hover {
  filter: brightness(0.98);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.ghost-button {
  background: var(--panel);
  color: #111827;
  border-color: var(--line);
}

.ghost-button:hover {
  background: var(--panel-soft);
}

.icon-only-button {
  width: 34px;
  padding: 0;
  color: #374151;
}

.icon-only-button svg,
.icon-text-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand-mark svg {
  width: 17px;
  height: 19px;
  fill: currentColor;
  stroke: none;
}

.icon-text-button svg {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
}

.topbar {
  width: min(1502px, calc(100vw - 40px));
  margin: 28px auto 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow-sm);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: #111827;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
}

.brand-lockup strong {
  display: inline;
  font-size: 12px;
  font-weight: 800;
}

.brand-lockup span:not(.brand-mark) {
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.app-shell {
  width: min(1502px, calc(100vw - 40px));
  margin: 0 auto 40px;
  padding: 16px 0 0;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(174px, 194px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
}

.summary-item {
  min-height: 66px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.summary-item span {
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.summary-item.ok span {
  color: var(--green);
}

.summary-item.warning span {
  color: var(--amber);
}

.summary-item.danger span {
  color: var(--red);
}

.summary-item.attention span {
  color: #3b82f6;
}

.summary-item small {
  display: inline-flex;
  width: fit-content;
  min-height: 22px;
  align-items: center;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-item.ok small,
.status-success {
  background: var(--green-soft);
  color: #059669;
}

.summary-item.warning small,
.status-warning {
  background: var(--amber-soft);
  color: #d97706;
}

.summary-item.danger small,
.status-danger {
  background: var(--red-soft);
  color: #dc2626;
}

.summary-item.attention small,
.status-attention {
  background: var(--blue-soft);
  color: #2563eb;
}

.report-button {
  height: 100%;
  min-height: 66px;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
}

.work-area {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.list-card,
.detail-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.list-pane {
  display: grid;
  gap: 8px;
}

.list-card {
  overflow: hidden;
}

.detail-pane {
  min-height: 720px;
  padding: 32px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
}

input::placeholder {
  color: #b3bac5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input.field-danger,
textarea.field-danger,
select.field-danger {
  border-color: rgba(239, 68, 68, 0.5);
  background: #fff5f5;
}

input.field-warning,
textarea.field-warning,
select.field-warning {
  border-color: rgba(245, 158, 11, 0.5);
  background: #fffbeb;
}

.business-list {
  max-height: 636px;
  overflow: auto;
  padding: 0;
}

.business-list::-webkit-scrollbar {
  width: 8px;
}

.business-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid var(--panel);
}

.business-row {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  text-align: left;
  box-shadow: none;
}

.business-row:hover,
.business-row.active {
  background: #f8fafc;
  filter: none;
}

.business-row.active {
  box-shadow: inset 3px 0 0 #93c5fd;
}

.business-name {
  display: block;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.business-meta {
  display: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 24px;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: none;
}

.hidden-tools {
  padding: 0 4px;
  background: transparent;
}

.hidden-toggle {
  min-height: 26px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  box-shadow: none;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  text-decoration: none;
}

.hidden-toggle-label {
  display: inline-block;
  text-decoration-line: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.hidden-toggle:hover {
  background: transparent;
  color: var(--blue);
}

.hidden-toggle span {
  margin: 0;
}

.hidden-business-list {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.hidden-business-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.hidden-business-link,
.restore-business-button {
  min-height: 28px;
  box-shadow: none;
  font-size: 11px;
}

.hidden-business-link {
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.restore-business-button {
  background: var(--panel);
  color: var(--blue);
  border: 1px solid var(--line);
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0;
}

.empty-state p {
  max-width: 440px;
}

.hidden {
  display: none !important;
}

.detail-form {
  display: grid;
  gap: 22px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.detail-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
}

#detailSubtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

#detailSubtitle strong {
  color: var(--ink);
  font-weight: 800;
}

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.subtle-danger-button {
  min-height: 36px;
  color: var(--ink);
  border-color: var(--line);
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
}

.subtle-danger-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--red);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.subtle-danger-button:hover {
  background: #fef2f2;
}

.subtle-danger-button.restore-mode {
  color: var(--blue);
}

.issue-panel {
  display: grid;
  gap: 8px;
}

.issue {
  min-height: 30px;
  border-radius: 3px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--blue-soft);
  border-left: 0;
  color: var(--blue);
  box-shadow: none;
}

.issue::before {
  content: "⚠";
  margin-right: 7px;
}

.issue.danger {
  background: var(--red-soft);
  color: #b91c1c;
}

.issue.warning {
  background: var(--amber-soft);
  color: #b45309;
}

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

.section-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex: 0 0 auto;
}

.section-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: none;
}

.ghl-logo svg {
  width: 15px;
  height: 14px;
}

.ghl-logo {
  background: var(--green);
}

.google-logo {
  background: #4285f4;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
  row-gap: 13px;
}

label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.field-value {
  min-height: 18px;
  width: 100%;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  padding: 1px 0;
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-transform: none;
}

.field-value.is-empty {
  display: inline;
  width: auto;
  min-height: 18px;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  padding: 1px 0;
  font-style: italic;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.field-value.field-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  padding: 2px 5px;
}

.field-value.field-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  padding: 2px 5px;
}

.field-value.is-empty.field-danger,
.field-value.is-empty.field-warning {
  background: transparent;
  color: #94a3b8;
  padding: 1px 0;
}

.wide {
  grid-column: span 1;
}

.notes-label {
  display: grid;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  gap: 5px;
}

.notes-label > span:first-child {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.notes-label textarea {
  min-height: 72px;
  border-color: #edf0f4;
  background: #f9fbff;
  color: var(--ink);
  resize: vertical;
}

.candidate-panel {
  display: grid;
  gap: 10px;
}

.candidate {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--panel-soft);
  box-shadow: none;
}

.candidate strong {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.candidate p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

dialog {
  width: min(700px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
  padding: 0;
}

#reportDialog {
  width: min(820px, calc(100vw - 32px));
}

#reportDialog form {
  background: #f3f5f8;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

dialog form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

dialog h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

pre {
  max-height: 55vh;
  overflow: auto;
  background: #f8fafc;
  color: var(--ink);
  border-radius: 6px;
  padding: 16px;
  white-space: pre-wrap;
  box-shadow: none;
}

.email-preview {
  max-height: 65vh;
  overflow: auto;
  border: 1px solid #dfe4eb;
  background: #e9edf2;
  padding: 22px;
}

.email-sheet {
  max-width: 680px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #e3e7ed;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

.email-header {
  padding: 30px 34px 28px;
  background: #151b28;
  color: #ffffff;
}

.email-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 30px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.email-brand-mark {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.email-header > p {
  margin: 0 0 7px;
  color: #80a7ff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.email-header h1 {
  max-width: 480px;
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.15;
}

.email-date {
  color: #abb5c6;
  font-size: 12px;
}

.email-body {
  padding: 30px 34px 32px;
}

.email-intro {
  margin: 0 0 22px;
  color: #657187;
  font-size: 13px;
}

.email-intro strong {
  color: #172033;
}

.email-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}

.email-metric {
  min-height: 70px;
  border: 1px solid #e3e7ed;
  border-top-width: 3px;
  border-radius: 5px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 5px;
  background: #ffffff;
}

.email-metric strong {
  font-size: 23px;
  line-height: 1;
}

.email-metric span {
  color: #7a8598;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.email-metric.ok {
  border-top-color: #10b981;
}

.email-metric.ok strong {
  color: #059669;
}

.email-metric.review {
  border-top-color: #f59e0b;
}

.email-metric.review strong {
  color: #d97706;
}

.email-metric.mismatch {
  border-top-color: #ef4444;
}

.email-metric.mismatch strong {
  color: #dc2626;
}

.email-metric.match {
  border-top-color: #3b82f6;
}

.email-metric.match strong {
  color: #2563eb;
}

.email-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #e3e7ed;
  padding-bottom: 12px;
}

.email-section-heading span {
  color: #ef4444;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.email-section-heading h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.email-section-heading > strong {
  color: #94a3b8;
  font-size: 24px;
}

.email-businesses {
  display: grid;
}

.email-business {
  border-bottom: 1px solid #edf0f4;
  padding: 14px 0;
}

.email-business-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.email-business-heading > strong {
  font-size: 12px;
}

.email-added {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.email-status {
  min-height: 19px;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.email-status.review {
  background: #fef3c7;
  color: #b45309;
}

.email-status.mismatch {
  background: #fee2e2;
  color: #dc2626;
}

.email-status.match {
  background: #dbeafe;
  color: #2563eb;
}

.email-status.ok {
  background: #d1fae5;
  color: #059669;
}

.email-business p {
  margin: 6px 0 0;
  color: #7a8598;
  font-size: 10px;
  line-height: 1.45;
}

.email-all-clear {
  padding: 28px 0;
  color: #059669;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.email-remaining {
  margin: 14px 0 0;
  color: #7a8598;
  font-size: 10px;
  text-align: center;
}

.email-footer {
  display: grid;
  gap: 5px;
  border-top: 1px solid #e3e7ed;
  padding: 20px 34px;
  background: #f9fbff;
}

.email-footer strong {
  font-size: 11px;
}

.email-footer span {
  color: #8a95a8;
  font-size: 9px;
}

#reportDialog .primary-link {
  justify-self: end;
}

@media (max-width: 980px) {
  .topbar,
  .app-shell {
    width: min(100vw - 24px, 720px);
  }

  .summary-band,
  .work-area {
    grid-template-columns: 1fr;
  }

  .report-button {
    min-height: 48px;
  }

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

  .email-preview {
    padding: 10px;
  }

  .email-header,
  .email-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .email-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
