:root {
  --bg: #f4f6f8;
  --panel-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #5b6779;
  /* PerkinElmer brand blue (PMS 7455 C / #204e9f) and a darker shade derived from it for
     hover/active states — every button, badge, and header in this file references these two
     variables rather than a hardcoded color, so this is the one place brand color lives. */
  --primary: #204e9f;
  --primary-dark: #163a77;
  --primary-contrast: #ffffff;

  --fact-badge-bg: #ecfdf5;
  --fact-badge-text: #047857;
  --fact-badge-border: #a7f3d0;

  /* Shifted to violet, distinct from --primary now that primary is a similar blue — this badge
     needs to stay visually distinguishable from brand-colored chrome (buttons, active tabs). */
  --ai-badge-bg: #f5f3ff;
  --ai-badge-text: #6d28d9;
  --ai-badge-border: #ddd6fe;

  --warn-bg: #fffbeb;
  --warn-text: #92400e;
  --warn-border: #fde68a;

  /* Light tint of --primary, for callouts that carry brand-colored text (timer, rank rationale) —
     kept separate from --fact-badge-* so that badge stays reserved for its "from public sources"
     meaning and doesn't get reused just because it happens to be a convenient light background. */
  --primary-tint-bg: #eaf0fb;
  --primary-tint-border: #c7d7f0;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app-header {
  background: var(--panel-bg);
  color: var(--text);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 15px;
  line-height: 1;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  line-height: 1.2;
}
.brand-tag {
  margin: 1px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--primary);
}
.tagline {
  margin: 2px 0 0;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}
.who-am-i {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.who-am-i:empty { display: none; }

/* --- Page footer ------------------------------------------------------------------------- */
.app-footer {
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
.footer-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 11px;
  line-height: 1;
}
.footer-brand-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}
.footer-brand:hover .footer-brand-name {
  color: var(--primary);
  text-decoration: underline;
}
.footer-legal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.footer-copy {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}
.footer-compliance {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  max-width: 480px;
}

main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

.search-panel, .results-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-panel { padding: 20px; position: sticky; top: 20px; }
@media (max-width: 900px) { .search-panel { position: static; } }
.results-panel { padding: 20px; min-height: 300px; }

.field-group { margin-bottom: 20px; }
.field-label, .field-label-row { display: block; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 8px; }
.field-label-row { display: flex; justify-content: space-between; align-items: center; }

.location-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab-btn {
  flex: 1; padding: 8px 10px; font-size: 13px; border: 1px solid var(--border); background: #fafbfc;
  border-radius: 8px; cursor: pointer; color: var(--text-muted);
}
.tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

#locationText, #customRadius, #routeFromText, #routeToText {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.route-fields:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
.route-fields .hint { margin: 0; }
.hint { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }

/* --- Location autocomplete + "use current location" shortcut --------------------------- */
.location-input-wrap { position: relative; flex: 1; min-width: 0; }
.route-input-row:not([hidden]) { display: flex; gap: 6px; align-items: center; }
.use-current-location-btn {
  flex-shrink: 0; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-bg); font-size: 15px; cursor: pointer; line-height: 1;
}
.use-current-location-btn:hover { background: var(--primary-tint-bg); border-color: var(--primary); }
.use-current-location-btn:disabled { opacity: 0.5; cursor: wait; }

.location-suggestions:not([hidden]) { display: block; }
.location-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  margin: 0; padding: 4px; list-style: none;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.location-suggestion {
  padding: 8px 10px; font-size: 13.5px; border-radius: 6px; cursor: pointer; white-space: normal;
}
.location-suggestion:hover, .location-suggestion.active { background: var(--primary-tint-bg); }

.radius-options { display: flex; flex-wrap: wrap; gap: 6px; }
.radius-pill {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fafbfc;
  font-size: 13px; cursor: pointer; color: var(--text-muted);
}
.radius-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.org-types-details { border: 1px solid var(--border); border-radius: 8px; }
.org-types-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; list-style: none;
}
.org-types-summary::-webkit-details-marker { display: none; }
.org-types-summary .field-label { margin-bottom: 0; }
.org-types-summary-meta { display: flex; align-items: center; gap: 8px; }
.org-types-count { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.org-types-chevron { color: var(--text-muted); font-size: 15px; transition: transform 0.15s ease; }
.org-types-details[open] .org-types-chevron { transform: rotate(90deg); }
.org-types-panel { padding: 0 12px 12px; border-top: 1px solid var(--border); }
.org-types-panel .field-label-row { margin: 10px 0 8px; }
.org-types-panel .hint { margin: 0; }

.org-types { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.org-type-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.org-type-item input { accent-color: var(--primary); width: 15px; height: 15px; }

.link-btn { background: none; border: none; color: var(--primary); font-size: 12.5px; cursor: pointer; padding: 0; text-decoration: underline; }

.primary-btn {
  width: 100%; padding: 11px; background: var(--primary); color: #fff; border: none; border-radius: 8px;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.secondary-btn {
  padding: 9px 14px; background: var(--panel-bg); color: var(--primary-dark); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.secondary-btn:hover { background: var(--primary-tint-bg); border-color: var(--primary); }
.list-actions:not([hidden]) { display: flex; justify-content: flex-end; margin-bottom: 12px; }

.elapsed-timer {
  margin: 10px 0 0; padding: 6px 10px; border-radius: 6px; text-align: center;
  font-size: 12.5px; font-weight: 600; color: var(--primary-dark); background: var(--primary-tint-bg);
  border: 1px solid var(--primary-tint-border);
}

.disclaimer { font-size: 11.5px; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }

/* --- Results panel tabs: Search Results / Shortlisted / Tracked Accounts ------------------ */
.results-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.results-tab {
  padding: 10px 14px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.results-tab:hover { color: var(--text); }
.results-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab-count {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--fact-badge-bg);
  color: var(--fact-badge-text);
  font-size: 11px;
  font-weight: 700;
}

.keyword-filter-row { margin-bottom: 12px; }
.keyword-filter {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit;
}

.status-line {
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text);
  padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px;
}
.empty-state { color: var(--text-muted); text-align: center; padding: 60px 20px; font-size: 14px; }

/* --- List view: compact rows (name + distance only) so browsing prospects never means
   scrolling past another organization's full detail/sources first ------------------------- */
.prospect-rows { display: flex; flex-direction: column; gap: 8px; }

.prospect-row {
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px; /* comfortable touch target on mobile */
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.prospect-row:not([hidden]) { display: flex; }
.prospect-row:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.prospect-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.star-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.star-btn:hover { background: var(--fact-badge-bg); color: #b45309; }
.star-btn.starred { color: #b45309; }
.card-title-row .star-btn { font-size: 20px; }

.row-rank {
  flex-shrink: 0;
  min-width: 26px; height: 22px; padding: 0 6px;
  background: var(--primary); color: #fff; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.row-rank:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-distance { flex-shrink: 0; font-size: 13px; color: var(--text-muted); }
.row-chevron { flex-shrink: 0; color: var(--text-muted); font-size: 20px; line-height: 1; }

/* --- Priority A/B/C: same tier, two places (list row + detail header) -------------------- */
.row-priority, .priority-badge {
  flex-shrink: 0;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; color: #fff;
}
.row-priority:not([hidden]), .priority-badge:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
.priority-badge { height: 26px; min-width: 26px; font-size: 12.5px; }
.priority-A { background: #b91c1c; }
.priority-B { background: #b45309; }
.priority-C { background: #6b7280; }

/* --- Detail view: one organization at a time, with a sticky way back -------------------- */
.back-btn {
  position: sticky;
  top: 0;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--primary-dark);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.back-btn:hover { background: var(--primary-tint-bg); }

.card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { padding: 16px 18px 10px; border-bottom: 1px solid var(--border); background: #fafcfc; }
.card-title-row { display: flex; align-items: center; gap: 10px; }
.rank-badge {
  min-width: 30px; height: 26px;
  background: var(--primary); color: #fff; border-radius: 999px; font-size: 12.5px; font-weight: 700; padding: 0 8px;
}
.rank-badge:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
.card-title { margin: 0; font-size: 17px; }
.card-subtitle { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.card-rationale { margin: 8px 0 0; font-size: 12.5px; color: var(--primary-dark); background: var(--primary-tint-bg); border: 1px solid var(--primary-tint-border); padding: 6px 10px; border-radius: 6px; }

.card-section { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-section:last-child { border-bottom: none; }

/* --- Status/Notes: status is the account's current state (one value); Notes is an append-only,
   timestamped activity log — each entry is read-only once added, so it's a record of what was
   actually said/done and when, not a single field that silently overwrites its own history.
   Both persist to the rep's server-side profile (see README "Shortlisted / Tracked Accounts"). */
.status-section { display: flex; gap: 16px; flex-wrap: wrap; background: #fafcfc; }
.status-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); flex: 0 0 200px; }
.notes-block { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.notes-label-text { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.status-select, .notes-textarea {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13.5px; color: var(--text);
  background: #fff;
}
.notes-textarea { resize: vertical; min-height: 38px; width: 100%; }
.note-form { display: flex; flex-direction: column; gap: 6px; }
.add-note-btn { align-self: flex-end; padding: 6px 12px; font-size: 12.5px; }
.notes-log { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.note-entry { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.note-date { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.note-text { margin: 0; font-size: 13px; white-space: pre-wrap; word-break: break-word; }

.section-title { margin: 0 0 10px; font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }

.badge { font-size: 10.5px; text-transform: none; letter-spacing: 0; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.fact-badge { background: var(--fact-badge-bg); color: var(--fact-badge-text); border: 1px solid var(--fact-badge-border); }
.ai-badge { background: var(--ai-badge-bg); color: var(--ai-badge-text); border: 1px solid var(--ai-badge-border); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 20px; margin-bottom: 10px; }
.summary-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.summary-value { display: block; font-size: 13.5px; word-break: break-word; }
.description { margin: 6px 0 0; font-size: 13.5px; }

.stakeholder-list, .opportunity-list, .product-list, .pitch-questions, .sources-list,
.persona-responsibilities, .persona-objectives, .persona-challenges {
  margin: 0; padding-left: 18px; font-size: 13.5px;
}
.stakeholder-list li, .opportunity-list li, .product-list li { margin-bottom: 8px; }
.confidence-tag { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; margin-left: 6px; border: 1px solid; }
.confidence-High { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.confidence-Medium { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.confidence-Low { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.opportunity-evidence { display: block; color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.opportunity-score { font-weight: 700; }

.persona-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.persona-grid h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-muted); }

.stakeholder-contact { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.stakeholder-links { margin-top: 2px; display: flex; gap: 10px; font-size: 12.5px; }
.stakeholder-links a { color: var(--primary-dark); }

.recommended-roles, .general-contact { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }
.general-contact a { color: var(--primary-dark); }

.installed-base-summary { font-size: 13.5px; margin: 0; }
.installed-base-vendors { font-size: 12.5px; font-weight: 600; margin: 6px 0 0; }
.installed-base-evidence:not([hidden]) { display: block; }
.installed-base-evidence { margin: 4px 0 0; }
.installed-base-evidence a { color: var(--primary-dark); }

.instrument-fit-section p { font-size: 13.5px; margin: 4px 0; }
.instrument-fit-name { font-weight: 700; }
.instrument-fit-score { font-weight: 700; color: var(--primary-dark); }
.instrument-fit-item { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.instrument-fit-item:last-child { border-bottom: none; padding-bottom: 0; }

.pitch-section p { font-size: 13.5px; margin: 6px 0; }
.pitch-displacement-line { color: var(--primary-dark); }

.sources-section { background: #fafcfc; }
.sources-details summary { cursor: pointer; }
.sources-details summary.section-title { margin-bottom: 0; }
.sources-details[open] summary.section-title { margin-bottom: 10px; }
.sources-count, .ask-sources-count { font-size: 12px; color: var(--text-muted); text-transform: none; font-weight: 500; }
.sources-list, .ask-sources-list { margin-top: 8px; }
.sources-list li, .ask-sources-list li { margin-bottom: 4px; word-break: break-word; }
.sources-list a, .ask-sources-list a { color: var(--primary-dark); }

.ask-section { background: #fafcfc; }
.ask-form { display: flex; gap: 8px; }
.ask-input {
  flex: 1; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  font-family: inherit;
}
.ask-btn { flex-shrink: 0; }
.ask-status { margin-top: 8px; }
.ask-result:not([hidden]) { display: block; }
.ask-result { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.ask-answer { margin: 0; font-size: 13.5px; white-space: pre-wrap; }
.ask-sources-list { padding-left: 18px; font-size: 13px; }

/* --- Territory summary: top accounts / competitive threats / opportunities / 30-day plan --- */
.summary-panel { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.summary-heading { margin: 0 0 14px; font-size: 16px; }
.summary-block { margin-bottom: 18px; }
.summary-block-title { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.summary-account-list, .summary-threat-list, .summary-opportunity-list { margin: 0; padding-left: 20px; font-size: 13.5px; }
.summary-account-list li, .summary-threat-list li, .summary-opportunity-list li { margin-bottom: 6px; }
.summary-account-list a { color: var(--primary-dark); font-weight: 600; }
.summary-plan { font-size: 13.5px; white-space: pre-wrap; margin: 0; background: #fafcfc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }

@media (max-width: 480px) {
  main { padding: 0 12px 40px; }
  .app-header {
    padding: 10px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .who-am-i { align-self: flex-start; white-space: normal; }
  .status-section { flex-direction: column; }
  .status-label { flex-basis: auto; }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
  }
  .footer-legal { align-items: flex-start; text-align: left; }
  .footer-compliance { max-width: 100%; }
}
