/* BitPetro Lead Engine - local viewer.
   Palette follows bitpetro.app: near-black ground, orange accent. */

:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1b1b1b;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f5;
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.34);
  --orange: #f7931a;
  --violet: #a78bfa;
  --slate: #7f9ab5;
  --green: #4ade80;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --header-h: 108px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

/* overflow-x lives on <html>, NEVER on <body> - on body it makes the body its
   own scroll container and silently kills position:sticky. AG-WEB-STANDARDS 5A. */
html {
  overflow-x: hidden;
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- sticky header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand:hover .brand-name { color: var(--orange); }

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color 0.2s;
}
.brand-name span { color: var(--orange); }

.brand-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
}

.search-wrap { flex: 1 1 260px; min-width: 200px; }

#search {
  width: 100%;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--orange); }
#search::placeholder { color: var(--faint); }

.presets { display: flex; gap: 6px; flex: 0 0 auto; }

.preset {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.preset:hover { border-color: var(--line-strong); color: var(--text); }
.preset[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #000;
}

.count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.count strong { color: var(--orange); }

.logout, .lang-selector-btn {
  padding: 8px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: 600 12px var(--sans);
  cursor: pointer;
}
.logout:hover, .lang-selector-btn:hover { border-color: var(--orange); }
.lang-selector-wrapper { position: relative; margin-left: auto; }
.lang-selector-btn { display: flex; gap: 6px; align-items: center; }
.lang-dropdown {
  display: none; position: absolute; top: calc(100% + 7px); right: 0; z-index: 100;
  width: 220px; padding: 8px; background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.lang-dropdown.open { display: block; }
.lang-search input { width: 100%; padding: 8px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; }
.lang-list { list-style: none; padding: 5px 0 0; margin: 0; }
.lang-list button { width: 100%; padding: 8px; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.lang-list button:hover, .lang-list button[aria-selected="true"] { background: rgba(247,147,26,.14); color: var(--orange); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; background: radial-gradient(circle at 50% 15%, #2b1b0a 0, var(--bg) 42%); }
.login-header .header-row { justify-content: space-between; }
.login-main { min-height: calc(100vh - 74px); display: grid; place-items: center; padding: 32px 18px; }
.login-card { width: min(430px, 100%); padding: 34px; background: rgba(20,20,20,.96); border: 1px solid var(--line-strong); border-top: 3px solid var(--orange); border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
.login-card h1 { margin: 5px 0 8px; font-size: 28px; }
.eyebrow { margin: 0; color: var(--orange); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.login-copy { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; margin: 0 0 16px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-card input { padding: 11px 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; font: 15px var(--sans); }
.login-card input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247,147,26,.12); }
.login-submit { width: 100%; padding: 11px; border: 0; border-radius: 6px; background: var(--orange); color: #000; font: 800 14px var(--sans); cursor: pointer; }
.login-submit:disabled { opacity: .55; cursor: wait; }
.login-error { padding: 9px 11px; border: 1px solid rgba(248,113,113,.45); border-radius: 6px; color: var(--red); background: rgba(248,113,113,.08); }

/* ---------- layout ---------- */

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

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  #facets { position: static !important; max-height: none !important; border-right: none; border-bottom: 1px solid var(--line); }
}

/* ---------- facets ---------- */

#facets {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 14px 40px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

#facets fieldset {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0 0 14px;
  padding: 12px 0 0;
}
#facets fieldset:first-of-type { border-top: none; padding-top: 0; }

#facets legend {
  padding: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-bottom: 8px;
}

.facet-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.facet-opt:hover { color: var(--text); }
.facet-opt input { accent-color: var(--orange); margin: 0; flex: 0 0 auto; }
.facet-opt .tally {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}

.facet-scroll { max-height: 168px; overflow-y: auto; }

#facets select,
#facets input[type="range"] {
  width: 100%;
  accent-color: var(--orange);
}
#facets select {
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.range-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.reset {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.reset:hover { border-color: var(--red); color: var(--red); }

/* ---------- table ---------- */

.table-wrap { overflow-x: auto; padding-bottom: 72px; }

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

thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-strong);
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  white-space: nowrap;
}
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); }
thead th .arrow { color: var(--orange); margin-left: 3px; }

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr.lead-row { cursor: pointer; }
tbody tr.lead-row:hover { background: rgba(247, 147, 26, 0.05); }
tbody tr.lead-row.open { background: rgba(247, 147, 26, 0.08); }

.num { font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.weight { font-family: var(--mono); font-weight: 700; color: var(--orange); }
.co { font-weight: 600; }
.sub { color: var(--faint); font-size: 12px; }
.nowrap { white-space: nowrap; }

.sel-cell { width: 30px; }
.sel-cell input { accent-color: var(--orange); cursor: pointer; }

/* ---------- pills ---------- */

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border: 1px solid currentColor;
}

.part-1 { color: var(--orange); }
.part-2 { color: var(--violet); }
.part-3 { color: var(--slate); }

.cs-verified        { color: var(--green); }
.cs-public-listed   { color: var(--blue); }
.cs-inferred-role   { color: var(--amber); }
.cs-company-general { color: var(--muted); }
.cs-none            { color: var(--red); }

.conf-high   { color: var(--green); background: rgba(74, 222, 128, 0.16); }
.conf-medium { color: var(--amber); background: rgba(251, 191, 36, 0.10); }
.conf-low    { color: var(--faint); background: transparent; }

.svc {
  display: inline-block;
  margin: 0 3px 2px 0;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* ---------- detail row ---------- */

.detail-cell { padding: 0 !important; border-bottom: 1px solid var(--line-strong) !important; }

.detail {
  border-left: 3px solid var(--orange);
  background: var(--panel);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 26px;
}
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

.detail h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.detail section { margin-bottom: 16px; }
.detail p { margin: 0 0 8px; color: rgba(255, 255, 255, 0.82); }

.detail blockquote {
  margin: 0;
  padding: 8px 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
  font-style: italic;
}

.opener {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.9);
}

.detail ul { margin: 0; padding-left: 16px; }
.detail li { margin-bottom: 3px; color: var(--muted); font-size: 13px; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--faint); white-space: nowrap; }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.bar-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 62px;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.bar-row .label { color: var(--muted); }
.bar-track { height: 6px; background: rgba(255, 255, 255, 0.07); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--orange); border-radius: 3px; }
.bar-row .val { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: right; }
.bar-row.total { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.bar-row.total .label, .bar-row.total .val { color: var(--orange); font-weight: 700; }

.status-select {
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

/* ---------- footer bar ---------- */

.footbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--panel-2);
  border-top: 1px solid var(--line-strong);
  flex-wrap: wrap;
}

.footbar button {
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.footbar button:hover { border-color: var(--orange); color: var(--orange); }
.footbar button.primary { background: var(--orange); border-color: var(--orange); color: #000; }
.footbar button.primary:hover { opacity: 0.88; color: #000; }

.footbar .spacer { flex: 1 1 auto; }
.footbar .meta { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.footbar .sel-count { font-family: var(--mono); font-size: 12px; color: var(--orange); font-weight: 700; }

.empty { padding: 60px 20px; text-align: center; color: var(--faint); }
