:root {
  --bg: #0b0c0f;
  --bg-2: #101217;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --line: #262a33;
  --line-2: #323744;
  --text: #ece8df;
  --muted: #9b978e;
  --faint: #6c6a64;
  --gold: #c8a96a;
  --gold-2: #e1c78f;
  --gold-ink: #17140d;
  --green: #74c69d;
  --green-bg: rgba(116, 198, 157, .12);
  --amber: #e0b154;
  --amber-bg: rgba(224, 177, 84, .13);
  --red: #e07a67;
  --red-bg: rgba(224, 122, 103, .12);
  --blue: #8fb3e8;
  --radius: 10px;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(200, 169, 106, .08), transparent 60%),
    radial-gradient(900px 400px at -10% 10%, rgba(143, 179, 232, .05), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 600; }
kbd {
  font: 500 11px var(--sans); padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); color: var(--text);
}

.banner {
  background: var(--red-bg); color: #f3c2b8; border-bottom: 1px solid rgba(224,122,103,.35);
  padding: 10px 24px; text-align: center; font-size: 13px;
}

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px); border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 15, .7); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { color: var(--gold); display: grid; place-items: center; }
.brand-name { font: 600 22px/1 var(--serif); letter-spacing: .3px; white-space: nowrap; }
.brand-name.sm { font-size: 20px; margin-bottom: 6px; }
.brand-sub { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 12px; color: var(--muted); background: var(--surface);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.pill.warn .dot { background: var(--amber); }
.pill.err .dot { background: var(--red); }

/* Hero */
.hero { padding: clamp(32px, 6vw, 64px) clamp(16px, 4vw, 48px) 24px; max-width: 1100px; }
.hero h1 { font: 500 clamp(32px, 4.6vw, 52px)/1.08 var(--serif); margin: 0 0 16px; letter-spacing: -.3px; }
.lede { color: var(--muted); font-size: 15.5px; max-width: 760px; margin: 0 0 24px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.steps li {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: linear-gradient(180deg, var(--surface), var(--bg-2)); color: var(--muted); font-size: 13px;
}
.steps li span {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(200,169,106,.5); color: var(--gold); font: 600 13px var(--serif);
}
.steps b { color: var(--text); }

/* Workspace */
.workspace { padding: 8px clamp(16px, 4vw, 48px) 32px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 14px; }
.toolbar .group { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: 500 13px var(--sans); cursor: pointer; transition: .15s ease;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--gold-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); color: var(--gold-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.progress { position: relative; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; margin-bottom: 12px; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(200,169,106,.25), rgba(200,169,106,.45)); transition: width .25s ease; }
.progress span { position: relative; display: block; padding: 5px 12px; font-size: 12.5px; color: var(--text); }

.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.stat { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; color: var(--muted); }
.stat b { display: block; font: 600 18px/1.2 var(--serif); color: var(--text); letter-spacing: .2px; }
.stat.g b { color: var(--green); } .stat.a b { color: var(--amber); } .stat.r b { color: var(--red); }

/* Grid */
.grid-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 68vh;
  background: var(--bg-2); box-shadow: 0 20px 60px -30px rgba(0,0,0,.8);
}
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; table-layout: fixed; }
.grid th {
  position: sticky; z-index: 2; background: #161a21; color: var(--muted); font: 600 11px/1.3 var(--sans);
  text-transform: uppercase; letter-spacing: .6px; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2);
  border-right: 1px solid var(--line); vertical-align: bottom;
}
.grid thead tr:first-child th { top: 0; }
.grid thead tr:nth-child(2) th { top: 30px; }
.grid thead tr.grp th { height: 30px; }
.grid th.grp-h { text-align: center; color: var(--gold); border-bottom: 1px solid var(--line); }
.grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; height: 34px; background: var(--surface); }
.grid tbody tr:hover td { background: #171b22; }
.grid tbody tr.sel td { background: #1b1f27; }
.grid input, .grid select {
  width: 100%; height: 34px; border: 0; outline: 0; background: transparent; color: var(--text);
  font: 13px var(--sans); padding: 0 10px; border-radius: 0;
}
.grid select { cursor: pointer; padding-right: 4px; }
.grid select option { background: var(--surface-2); color: var(--text); }
.grid input:focus, .grid select:focus { box-shadow: inset 0 0 0 1.5px var(--gold); background: rgba(200,169,106,.06); }
.grid input::placeholder { color: var(--faint); }
.grid .c-amt input, .grid td.c-amt { text-align: right; font-variant-numeric: tabular-nums; }
.grid .changed input { color: var(--gold-2); }
.grid td.in-sel {
  --st: 0 0 transparent; --sb: 0 0 transparent; --sl: 0 0 transparent; --sr: 0 0 transparent;
  background: rgba(200, 169, 106, .14) !important;
  box-shadow: inset var(--st), inset var(--sb), inset var(--sl), inset var(--sr);
}
.grid td.sel-t { --st: 0 2px 0 var(--gold); }
.grid td.sel-b { --sb: 0 -2px 0 var(--gold); }
.grid td.sel-l { --sl: 2px 0 0 var(--gold); }
.grid td.sel-r { --sr: -2px 0 0 var(--gold); }
.grid thead th { cursor: pointer; user-select: none; }
.grid thead th.grp-h { cursor: default; }
.grid thead th:not(.grp-h):hover { color: var(--gold-2); }
.rownum { cursor: pointer; user-select: none; }

.c-st { width: 118px; } .c-name { width: 290px; } .c-addr { width: 210px; } .c-city { width: 130px; } .c-state { width: 64px; }
.c-zip { width: 106px; } .c-prov { width: 100px; } .c-country { width: 110px; } .c-irs { width: 112px; } .c-purpose { width: 300px; }
.c-amt { width: 120px; } .c-ver { width: 150px; } .c-ref { width: 170px; }
.grid th.c-st, .grid td.c-st { position: sticky; left: 0; z-index: 3; }
.grid thead th.c-st { z-index: 4; }

.st-cell { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 8px; height: 34px; }
.rownum { color: var(--faint); font-size: 11px; width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 2px 8px; font: 500 11px var(--sans); cursor: pointer; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.verified { color: var(--green); border-color: rgba(116,198,157,.35); background: var(--green-bg); }
.badge.review { color: var(--amber); border-color: rgba(224,177,84,.4); background: var(--amber-bg); }
.badge.not_verified, .badge.not_found, .badge.error { color: var(--red); border-color: rgba(224,122,103,.35); background: var(--red-bg); }
.badge.working { color: var(--blue); border-color: rgba(143,179,232,.35); }
.badge.working::before { animation: pulse 1s infinite ease-in-out; }
.badge.empty { visibility: hidden; }
@keyframes pulse { 50% { opacity: .2; } }
.row-del { margin-left: auto; background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 16px; padding: 0 2px; visibility: hidden; }
tr:hover .row-del { visibility: visible; }
.row-del:hover { color: var(--red); }

td.c-ver select.v-yes { color: var(--green); font-weight: 600; }
td.c-ver select.v-no { color: var(--red); }
.ref-cell { display: flex; align-items: center; }
.ref-cell input { flex: 1; min-width: 0; }
.ref-cell a { padding: 0 8px; color: var(--gold); font-size: 13px; }

.grid tfoot td { position: sticky; bottom: 0; background: #161a21; border-top: 1px solid var(--line-2); font-weight: 600; height: 38px; padding: 0 10px; }
.grid tfoot td.c-st { padding: 0; }
.tot-label { text-align: right; color: var(--muted); font-weight: 500 !important; text-transform: uppercase; font-size: 11px; letter-spacing: .6px; }
.tot { color: var(--gold-2); font-variant-numeric: tabular-nums; border-bottom: 3px double var(--gold) !important; }

.hint { color: var(--faint); font-size: 12.5px; margin: 10px 2px 0; }
.legend { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 16px; }
.legend summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.legend ul { columns: 2 380px; margin: 10px 0 4px; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.legend li { margin-bottom: 4px; break-inside: avoid; }
.legend li b { color: var(--text); }

/* Drawer */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 100vw); background: var(--bg-2);
  border-left: 1px solid var(--line-2); z-index: 50; transform: translateX(105%); transition: transform .22s ease;
  display: flex; flex-direction: column; box-shadow: -30px 0 60px -20px rgba(0,0,0,.6);
}
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 500 26px/1.15 var(--serif); margin: 4px 0 0; }
.eyebrow { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); }
.drawer-body { padding: 18px 22px 40px; overflow: auto; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.sec-title { font: 600 11px var(--sans); letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.notes { margin: 0; padding-left: 18px; color: var(--text); font-size: 13px; }
.notes li { margin-bottom: 6px; }
.cand { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--surface); }
.cand .meta { flex: 1; min-width: 0; }
.cand .nm { font-weight: 500; }
.cand .sub { color: var(--muted); font-size: 12px; }
.score { font: 600 15px var(--serif); color: var(--gold); width: 38px; text-align: right; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.ein-row { display: flex; gap: 8px; }
.ein-row input {
  flex: 1; background: var(--surface); border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; padding: 8px 10px; font: 13px var(--sans);
}
.suggest { border: 1px solid rgba(224,177,84,.4); background: var(--amber-bg); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.suggest .nm { font: 500 18px var(--serif); margin: 2px 0 4px; }

/* Modal */
.modal { border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); border-radius: 14px; padding: 26px 28px; width: min(560px, 92vw); }
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal h2 { font: 500 28px var(--serif); margin: 0 0 8px; }
.modal h3 { font-size: 14px; margin: 20px 0 6px; color: var(--gold-2); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.field { display: block; margin: 12px 0 8px; font-size: 13px; color: var(--muted); }
.field input { display: block; width: 100%; margin-top: 6px; background: var(--surface); border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; padding: 9px 12px; font: 13px var(--sans); }
.field input:focus { outline: none; border-color: var(--gold); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 6px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0 12px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); padding: 10px 18px; border-radius: 10px;
  font-size: 13px; transition: .2s ease; z-index: 80; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Footer */
.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 28px clamp(16px, 4vw, 48px) 40px; color: var(--muted); font-size: 12.5px; }
.foot-grid { display: grid; grid-template-columns: 1fr 1.2fr 1.6fr; gap: 28px; max-width: 1400px; }
.foot p { margin: 0; }
.foot p.site { margin-top: 8px; }
.disclaimer { color: var(--faint); }

@media (max-width: 900px) {
  .foot-grid { grid-template-columns: 1fr; }
  .top { padding: 14px 16px; }
  .brand-sub { display: none; }
}
@media (max-width: 560px) {
  #dataStatus .txt { display: none; }
  #dataStatus { padding: 8px; }
  .toolbar .group { width: 100%; }
  .hero h1 { font-size: 30px; }
}
