:root {
  --navy: #0e1a2b;   /* matches the logo (brand/analyst-atlas-mark.svg) */
  --navy-2: #1b3560;
  --gold: #c8a45d;   /* matches the logo's antique gold */
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #5c6880;
  --border: #dde3ee;
  --green: #1f8a4c;
  --radius: 12px;
  --focus: #1a66d6; /* keyboard focus ring: 3:1+ against white, the page background and cards */
}

/* ---------- Accessibility helpers ---------- */
/* Text read by screen readers but not shown on screen. */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* "Skip to firm list" link: hidden until a keyboard user tabs to it. */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 3000;
  background: #fff; color: var(--navy); font-weight: 600; font-size: 14px;
  padding: 10px 14px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.skip-link:focus { top: 8px; }
/* Visible focus ring for keyboard users (mouse clicks don't show it). */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.topbar :focus-visible { outline-color: #fff; }
#list:focus { outline: none; }
/* Respect "reduce motion" in the operating system. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: block; width: auto; height: 44px; flex-shrink: 0; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.tagline { margin: 2px 0 0; font-size: 13px; color: #b9c6dd; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--navy); font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--navy-2); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { border-color: #fff; }

/* Filters */
.controls {
  display: flex; flex-wrap: wrap; gap: 12px; padding: 14px 24px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field.grow { flex: 1; min-width: 220px; }
.field select, .field input {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-width: 170px;
}

/* Layout */
.layout { flex: 1; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; min-height: 0; }
/* position: relative keeps the screen-reader-only text (absolutely positioned) inside this
   scroll area; without it, that text stretches the whole page and adds a stray page scroll. */
.results { overflow-y: auto; padding: 16px 20px 40px; position: relative; }
.card { position: relative; }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }
.count { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.list { display: flex; flex-direction: column; gap: 12px; }

/* Firm card */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: 0 4px 16px rgba(15,35,64,.08); }
.card.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200,164,93,.35); }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h2 { margin: 0; font-size: 17px; color: var(--navy); }
.meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.badge.hiring { background: #e5f5ec; color: #17663a; } /* darker green: 4.5:1 contrast at 11px */
.badge.cold { background: #eef2f8; color: var(--navy-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge.cat { background: var(--navy); color: #fff; }
.badge.finra { background: #fff4d6; color: #7a5d00; }
.badge.tier { background: #eef2f8; color: var(--navy-2); border: 1px solid var(--border); }
.legend { margin: 10px 0 4px; font-size: 13px; line-height: 1.45; }
.legend dt { font-weight: 700; color: var(--navy); margin-top: 8px; }
.legend dd { margin: 2px 0 0; color: var(--text); }
.addr, .hq { font-size: 13px; color: var(--text); margin: 0 0 4px; }
.hq { color: var(--muted); }
.tags { margin-top: 8px; }
.hiring-note {
  font-size: 13px; background: #f7f9fc; border-left: 3px solid var(--gold);
  padding: 8px 10px; margin: 0 0 10px; border-radius: 4px; line-height: 1.4;
}
.verified { font-size: 11px; color: var(--muted); margin: 10px 0 0; }

/* Cold-apply tips */
.tips {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
.tips summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.tips ol { margin: 10px 0 4px; padding-left: 20px; line-height: 1.45; }
.tips li { margin-bottom: 6px; }
.desc { font-size: 14px; line-height: 1.45; margin: 10px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: 12px; background: #eef2f8; color: var(--navy-2); padding: 3px 8px; border-radius: 6px; }

.roles { list-style: none; padding: 0; margin: 0 0 12px; border-top: 1px solid var(--border); }
.roles li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.roles .role-type { font-size: 12px; color: var(--muted); }
.roles a { color: var(--navy-2); font-weight: 600; font-size: 13px; }
.no-roles { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

.contact { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty p { margin: 0 0 12px; }
.pro-teaser { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--navy); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.verified a { color: var(--navy-2); }

/* Map pins */
.pin {
  width: 28px; height: 28px; background: #e8453c; border: 2px solid #fff;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.pin span { width: 9px; height: 9px; background: #fff; border-radius: 50%; }
.pin:hover { transform: rotate(-45deg) scale(1.15); }
.pin.approx { background: #7b8494; }

/* Cleaner Leaflet controls and popups */
.leaflet-bar { border: none !important; box-shadow: 0 1px 4px rgba(0,0,0,.25) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-bar a { width: 34px !important; height: 34px !important; line-height: 34px !important; color: #444 !important; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.leaflet-container { font-family: inherit; background: #e8e8e8; }

/* Map popup */
.popup h3 { margin: 0 0 4px; font-size: 15px; color: var(--navy); }
.popup p { margin: 0 0 8px; font-size: 13px; }
.popup .actions .btn { padding: 5px 9px; font-size: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Header nav ---------- */
a.brand { color: inherit; text-decoration: none; }
.nav { display: flex; gap: 8px; align-items: center; }
#account-nav { display: flex; gap: 8px; }
.btn-gold { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-gold:hover { filter: brightness(1.05); border-color: var(--gold); }
.btn-save.saved { background: #f7efdf; border-color: var(--gold); color: #6b5426; }
.btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.demo-banner { background: #fff4d6; color: #6b5200; text-align: center; font-size: 13px; padding: 6px 12px; }

/* ---------- Sign-in & account pages ---------- */
body.page { height: auto; min-height: 100%; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel h3 { margin: 0 0 6px; color: var(--navy); font-size: 17px; }
.auth-wrap { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; }
.auth-panel { width: 100%; max-width: 400px; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  flex: 1; background: none; border: none; padding: 10px; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form.inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.input { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input small { font-weight: 400; }
.input input, .input select {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--text);
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.input input:focus, .input select:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.link { background: none; border: none; color: var(--navy-2); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; align-self: center; }
.fine { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert.error { background: #fdecea; color: #a12a1e; }
.alert.success { background: #e5f5ec; color: #17663a; }

.account { width: 100%; max-width: 820px; margin: 0 auto; padding: 28px 16px 60px; display: flex; flex-direction: column; gap: 16px; }
.account[hidden] { display: none; }
.account-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.account-head h2 { margin: 0; color: var(--navy); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }
.plan-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.saved { list-style: none; margin: 0; padding: 0; }
.saved li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.panel.danger { border-color: #f1c4bf; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Admin ---------- */
.account.admin { max-width: 1100px; }
.admin-tag { font-size: 12px; background: var(--gold); color: var(--navy); padding: 2px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-v { font-size: 22px; font-weight: 700; color: var(--navy); }
.stat-k { font-size: 12px; color: var(--muted); margin-top: 2px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h3 { margin: 0; }
.change { border-top: 1px solid var(--border); padding: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.change p { margin: 0; font-size: 14px; }
.change-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.evidence { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.patch, #editor-json {
  width: 100%; min-height: 140px; font: 12.5px/1.45 ui-monospace, Consolas, monospace;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; resize: vertical; color: var(--text);
}
.diff { font: 12.5px/1.5 ui-monospace, Consolas, monospace; background: #f7f9fc; border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; }
.diff .add { color: #17663a; } .diff .del { color: #a12a1e; }
.badge.kind-content, .badge.kind-ats { background: #e5f5ec; color: var(--green); }
.badge.kind-page_changed { background: #eef2f8; color: var(--navy-2); }
.badge.kind-redirect, .badge.kind-site_down { background: #fdecea; color: #a12a1e; }
.badge.st-ok { background: #e5f5ec; color: var(--green); }
.badge.st-warning { background: #fff4d6; color: #7a5d00; }
.badge.st-error { background: #fdecea; color: #a12a1e; }
.badge.st-pending { background: #eef2f8; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.firms-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.firms-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); }
.firms-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.firms-table td.actions { white-space: nowrap; }
.firms-table tr.inactive { opacity: .55; }
.editor { border: none; border-radius: var(--radius); padding: 20px; width: min(720px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.editor::backdrop { background: rgba(15,35,64,.45); }
.editor h3 { margin: 0 0 6px; color: var(--navy); }
#editor-json { min-height: 380px; margin-bottom: 12px; }

/* ---------- Firm card: dropdown rows, deals, bookmark, scrolling action row ---------- */
.c2-section { border-top: 1px solid var(--border); margin-top: 10px; }
.c2-section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 9px 2px; font-size: 13px; font-weight: 600; color: var(--navy);
}
.c2-section > summary::-webkit-details-marker { display: none; }
/* Chevron drawn with CSS borders (no emoji / font glyph) */
.c2-section > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; margin-right: 4px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg); transition: transform .15s;
}
.c2-section[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.c2-ico { width: 16px; height: 16px; flex: 0 0 16px; color: var(--navy-2); }
.addr .c2-ico { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--muted); }
.c2-section .c2-body { padding: 0 2px 10px; font-size: 13px; line-height: 1.45; }
.c2-count { font-weight: 500; color: var(--muted); }
.c2-deals { list-style: none; margin: 0; padding: 0; }
.c2-deals li { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.c2-deals li:last-child { border-bottom: none; }
.c2-deal-date { color: var(--muted); font-size: 12px; padding-top: 1px; }
/* Deal links are underlined so they can be told apart from plain deal text without relying on color. */
.c2-deals a { color: var(--text); text-decoration: underline; text-decoration-color: #aab4c8; text-underline-offset: 2px; }
.c2-deals a:hover { text-decoration-color: currentColor; color: var(--navy-2); }
.c2-deal-type { display: inline-block; font-size: 11px; color: var(--navy-2); background: #eef2f8; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.c2-all { display: inline-block; margin-top: 6px; font-weight: 600; color: var(--navy-2); font-size: 12px; }

/* Bookmark (save) button in the card's top-right corner */
.c2-bookmark {
  flex: 0 0 auto; width: 34px; height: 34px; margin: -4px -6px 0 0; border: none; background: transparent;
  border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted);
}
.c2-bookmark:hover { background: #eef2f8; color: var(--navy); }
.c2-bookmark svg { width: 20px; height: 20px; }
.c2-bookmark.saved { color: #a88412; } /* darker gold so the icon has 3:1 contrast on white */
.c2-bookmark.saved svg path { fill: currentColor; }

/* Badge sitting at the right end of a section row ("Hiring info ---- Cold-apply") */
.c2-section > summary .badge, .c2-row .badge { margin-left: auto; }
.c2-section > summary:has(.badge)::after { margin-left: 10px; }
.c2-row {   /* same look as a section row, but not expandable */
  display: flex; align-items: center; gap: 8px; padding: 9px 2px; font-size: 13px; font-weight: 600;
  color: var(--navy); border-top: 1px solid var(--border); margin-top: 10px;
}
.c2-row a { margin-left: auto; font-weight: 600; color: var(--navy-2); font-size: 12.5px; }

.c2-contact { font-size: 12.5px; color: var(--muted); margin: 12px 0 8px; line-height: 1.4; }
.c2-contact strong { color: var(--text); font-weight: 600; }

/* Horizontally scrolling action row.
   - Buttons line up exactly with the card's text: the 4px padding (room for the keyboard focus ring,
     which would otherwise be clipped) is cancelled out by a matching -4px margin.
   - Mouse wheel and click-drag scroll it (see JS); scrollbar hidden.
   - Edge fades appear only on the side that has more buttons hidden. */
.c2-actions {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 4px; margin: 0 -4px; cursor: grab; user-select: none;
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.c2-actions::-webkit-scrollbar { display: none; }
.c2-actions.dragging { cursor: grabbing; }
.c2-actions.dragging a, .c2-actions.dragging button { pointer-events: none; }
.c2-actions.more-left { --fade-l: 36px; }
.c2-actions.more-right { --fade-r: 36px; }
.c2-actions .btn {
  flex: 0 0 auto; height: 32px; padding: 0 12px; font-size: 12.5px; line-height: 1;
  border-radius: 999px; display: inline-flex; align-items: center;
}

.c2-actions .btn:focus-visible { outline-offset: 1px; }

.card .verified { display: none; }
.card.active .verified { display: block; }

/* ---------- Site footer ---------- */
.site-footer { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.site-footer a { color: var(--navy-2); font-weight: 600; }
.site-footer p { margin: 0 0 6px; }
body.page > .site-footer { margin: 0; padding: 18px 16px 28px; background: #fff; }
body.page > .site-footer > * { max-width: 820px; margin-left: auto; margin-right: auto; }

/* ---------- Legal pages (Terms, Privacy, Accessibility) ---------- */
.legal { width: 100%; max-width: 820px; margin: 0 auto; padding: 28px 16px 48px; flex: 1; }
.legal article { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px clamp(18px, 4vw, 40px); line-height: 1.6; font-size: 15px; }
.legal h2 { margin: 0 0 4px; color: var(--navy); font-size: 26px; }
.legal h3 { margin: 28px 0 6px; color: var(--navy); font-size: 17px; }
.legal .updated { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.legal ul { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--navy-2); }
.legal a.btn-primary { color: #fff; text-decoration: none; }
.legal .callout { background: #f7f9fc; border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 4px; margin: 16px 0; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 4px; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--border); }
.legal th { color: var(--muted); font-size: 12.5px; }
.table-scroll { overflow-x: auto; }

/* Mobile: stack map on top of list */
@media (max-width: 860px) {
  .topbar { padding: 12px 16px; }
  .tagline { display: none; }
  .controls { padding: 12px 16px; }
  .field select, .field input { min-width: 0; width: 100%; }
  .field { flex: 1 1 140px; }
  .layout { display: flex; flex-direction: column; min-height: auto; }
  .map-wrap { flex: 0 0 300px; order: -1; }
  .results { overflow: visible; padding: 16px; }
}
