:root {
  --bg: #090b10;
  --surface: #111319;
  --card: #161820;
  --card-hover: #1c1f2a;
  --border: #1e2130;
  --border-light: #252840;
  --primary: #6366f1;
  --primary-glow: rgba(99,102,241,0.15);
  --accent: #22d3ee;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --muted: #4a5068;
  --text: #e8eaf6;
  --text-secondary: #8890aa;
  --sidebar-w: 220px;
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; overflow: hidden; }
a { color: inherit; text-decoration: none; }

/* Layout */
#app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; background: linear-gradient(135deg, #6366f1, #818cf8); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; color: #fff; flex-shrink: 0; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.brand-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.sidebar-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-section { margin-bottom: 18px; }
.nav-section-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; color: var(--muted); padding: 0 10px 6px; text-transform: uppercase; display: block; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; cursor: pointer; transition: background 0.15s, color 0.15s; color: var(--text-secondary); font-size: 13.5px; font-weight: 500; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .nav-badge { margin-left: auto; font-size: 11px; background: var(--border); color: var(--text-secondary); border-radius: 10px; padding: 1px 7px; font-weight: 700; }
.nav-item.active .nav-badge { background: var(--primary-glow); color: var(--primary); }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.live-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.live-dot::before { content: ''; display: block; width: 6px; height: 6px; background: var(--green); border-radius: 50%; animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Main */
.main { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.view { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.view.active { display: flex; }

/* Topbar */
.topbar { padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar h1 { font-size: 17px; font-weight: 800; letter-spacing: -0.03em; }
.topbar .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Search */
.search-wrap { position: relative; flex: 1; max-width: 340px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.search-wrap input { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px 7px 32px; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.2s; font-family: var(--font); }
.search-wrap input:focus { border-color: var(--primary); }
.search-wrap input::placeholder { color: var(--muted); }

/* Filter selects */
select.fsel { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 7px 28px 7px 10px; color: var(--text); font-size: 12.5px; outline: none; cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234a5068' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; font-family: var(--font); }
select.fsel:focus { border-color: var(--primary); }

/* Scroll */
.scroll { flex: 1; overflow-y: auto; padding: 18px 22px; }
.scroll::-webkit-scrollbar { width: 5px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Contract cards */
.contract-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.ccard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; cursor: pointer; transition: border-color 0.2s, background 0.2s, transform 0.12s; position: relative; overflow: hidden; }
.ccard::before { content:''; position:absolute; top:0;left:0;right:0; height:2px; background:linear-gradient(90deg,var(--primary),var(--accent)); opacity:0; transition:opacity 0.2s; }
.ccard:hover { background: var(--card-hover); border-color: var(--border-light); transform: translateY(-1px); }
.ccard:hover::before { opacity:1; }
.ccard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.ccard-company { font-size: 14px; font-weight: 700; line-height: 1.3; flex: 1; }
.ccard-value { font-size: 14px; font-weight: 800; color: var(--accent); white-space: nowrap; flex-shrink: 0; }
.ccard-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 10px; }
.ccard-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chip { font-size: 11px; color: var(--text-secondary); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 18px 0 4px; }
.pbn { background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 6px 11px; color: var(--text-secondary); font-size: 12.5px; cursor: pointer; transition: all 0.15s; font-family: var(--font); }
.pbn:hover { border-color: var(--primary); color: var(--primary); }
.pbn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pbn:disabled { opacity: 0.3; cursor: default; }

/* ── Detail view ── */
.back-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; transition: color 0.15s; flex-shrink: 0; }
.back-btn:hover { color: var(--text); }
.back-btn svg { width: 15px; height: 15px; }

.detail-layout { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.detail-left { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 22px; }
.detail-left::-webkit-scrollbar { width: 5px; }
.detail-left::-webkit-scrollbar-track { background: transparent; }
.detail-left::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.detail-right { width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; padding: 18px; background: var(--surface); }
.detail-right::-webkit-scrollbar { width: 5px; }
.detail-right::-webkit-scrollbar-track { background: transparent; }
.detail-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Contract header */
.ch-company { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 4px; }
.ch-piid { font-size: 11px; color: var(--muted); font-family: monospace; margin-bottom: 10px; }
.ch-desc { font-size: 13.5px; color: var(--text-secondary); line-height: 1.65; max-width: 620px; margin-bottom: 12px; }
.ch-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.value-pill { font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: -0.03em; }

/* Badges */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.badge-green { background: rgba(16,185,129,0.14); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.14); color: var(--red); }
.badge-yellow { background: rgba(245,158,11,0.14); color: var(--yellow); }
.badge-blue { background: rgba(99,102,241,0.14); color: var(--primary); }
.badge-cyan { background: rgba(34,211,238,0.12); color: var(--accent); }
.badge-muted { background: var(--border); color: var(--muted); }

/* Enrich CTA */
.enrich-cta { background: linear-gradient(135deg,rgba(99,102,241,0.1),rgba(34,211,238,0.06)); border: 1px solid rgba(99,102,241,0.28); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.enrich-cta.is-enriched { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.2); }
.enrich-cta .cta-text h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.enrich-cta .cta-text p { font-size: 12px; color: var(--text-secondary); }
.btn-enrich { background: linear-gradient(135deg,var(--primary),#818cf8); color: #fff; border: none; border-radius: 8px; padding: 9px 17px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; flex-shrink: 0; transition: opacity 0.15s; font-family: var(--font); }
.btn-enrich:hover { opacity: 0.88; }
.btn-enrich:disabled { opacity: 0.45; cursor: not-allowed; }

/* Section cards */
.scard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.scard-head { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
.scard-head svg { width: 15px; height: 15px; color: var(--primary); flex-shrink: 0; }
.scard-head h3 { font-size: 13px; font-weight: 700; flex: 1; }
.scard-head .chevron { width: 13px; height: 13px; color: var(--muted); transition: transform 0.2s; margin-left: auto; }
.scard.collapsed .chevron { transform: rotate(-90deg); }
.scard.collapsed .scard-body { display: none; }
.scard-body { padding: 14px 15px; }

/* Data grid */
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.drow { display: flex; flex-direction: column; gap: 2px; }
.drow.full { grid-column: 1/-1; }
.dlabel { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.dval { font-size: 13px; color: var(--text); font-weight: 500; }
.dval.mono { font-family: monospace; font-size: 12px; }
.dval a { color: var(--primary); }
.dval a:hover { text-decoration: underline; }
.dval.empty { color: var(--muted); font-style: italic; }

/* Risk meter */
.risk-meter { margin-bottom: 14px; }
.risk-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.risk-score { font-size: 36px; font-weight: 800; letter-spacing: -0.04em; }
.risk-score.high { color: var(--green); }
.risk-score.medium { color: var(--yellow); }
.risk-score.low { color: var(--red); }
.risk-score.unknown { color: var(--muted); }
.risk-tier { font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.06em; }
.rt-low { background: rgba(16,185,129,0.15); color: var(--green); }
.rt-medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.rt-high { background: rgba(239,68,68,0.15); color: var(--red); }
.rt-critical { background: rgba(239,68,68,0.25); color: #ff6b6b; }
.rt-unknown { background: var(--border); color: var(--muted); }

/* Score bars */
.sbar { margin-bottom: 8px; }
.sbar-top { display: flex; justify-content: space-between; margin-bottom: 3px; font-size: 11.5px; }
.sbar-label { color: var(--text-secondary); }
.sbar-val { font-weight: 700; }
.sbar-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sbar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

/* Flag / indicator lists */
.flaglist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.flagitem { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
.fdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.fdot.red { background: var(--red); }
.fdot.green { background: var(--green); }

.risk-memo-text { font-size: 12.5px; color: var(--text-secondary); line-height: 1.75; white-space: pre-wrap; }
.citations { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; }
.citation-link { font-size: 11.5px; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.citation-link:hover { text-decoration: underline; }

/* Officers */
.officer-list { display: flex; flex-direction: column; gap: 7px; }
.officer { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--surface); border-radius: 7px; border: 1px solid var(--border); }
.officer-av { width: 30px; height: 30px; background: var(--primary-glow); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.officer-name { font-size: 12.5px; font-weight: 600; }
.officer-role { font-size: 11.5px; color: var(--text-secondary); }

/* UCC box */
.ucc-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; }
.ucc-box svg { color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.ucc-box a { color: var(--accent); font-size: 13px; font-weight: 600; display: block; margin-bottom: 4px; }
.ucc-box a:hover { text-decoration: underline; }
.ucc-box p { font-size: 12px; color: var(--muted); }

/* Contact sidebar */
.sidebar-section-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; display: block; }
.contact-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 9px; }
.cc-name { font-size: 13px; font-weight: 700; margin-bottom: 1px; }
.cc-title { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; }
.cc-links { display: flex; flex-direction: column; gap: 4px; }
.cc-link { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); overflow: hidden; }
.cc-link svg { width: 11px; height: 11px; flex-shrink: 0; color: var(--muted); }
.cc-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-link a { color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.btn-outreach { display: flex; align-items: center; justify-content: center; gap: 5px; width: 100%; background: transparent; border: 1px solid var(--primary); border-radius: 7px; padding: 6px; color: var(--primary); font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: background 0.15s; font-family: var(--font); }
.btn-outreach:hover { background: var(--primary-glow); }
.btn-outreach svg { width: 11px; height: 11px; }

.no-contacts { text-align: center; padding: 18px 10px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ── Outreach ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; }
.sc-label { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 7px; }
.sc-value { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 2px; }
.sc-value.cyan { color: var(--accent); }
.sc-value.green { color: var(--green); }
.sc-value.yellow { color: var(--yellow); }
.sc-value.red { color: var(--red); }
.sc-value.primary { color: var(--primary); }
.sc-sub { font-size: 11px; color: var(--muted); }

.section-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

.send-status { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 20px; display: flex; align-items: center; gap: 12px; }
.ss-icon { width: 36px; height: 36px; background: var(--primary-glow); border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ss-icon svg { width: 17px; height: 17px; color: var(--primary); }
.ss-text h4 { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.ss-text p { font-size: 12px; color: var(--text-secondary); }

.tbl-wrap { overflow-x: auto; }
table.etbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.etbl th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
table.etbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
table.etbl tr:last-child td { border-bottom: none; }
table.etbl tr:hover td { background: var(--card-hover); color: var(--text); }
table.etbl td:first-child { font-weight: 600; color: var(--text); }
.estatus { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.es-sent { background: rgba(99,102,241,0.14); color: var(--primary); }
.es-delivered { background: rgba(16,185,129,0.1); color: var(--green); }
.es-opened { background: rgba(34,211,238,0.12); color: var(--accent); }
.es-clicked { background: rgba(245,158,11,0.12); color: var(--yellow); }
.es-replied { background: rgba(16,185,129,0.2); color: #34d399; }
.es-bounced { background: rgba(239,68,68,0.12); color: var(--red); }

/* Loading / skeleton */
.skel { background: linear-gradient(90deg,var(--card) 25%,var(--card-hover) 50%,var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--text-secondary); font-size: 13px; }

/* Empty */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 20px; color: var(--muted); gap: 8px; }
.empty svg { width: 36px; height: 36px; opacity: 0.35; }
.empty h3 { font-size: 15px; color: var(--text-secondary); }
.empty p { font-size: 12.5px; }

/* Toast */
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); z-index: 999; transform: translateY(16px); opacity: 0; transition: transform 0.22s, opacity 0.22s; max-width: 300px; pointer-events: none; }
#toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
#toast.ok { border-color: var(--green); }
#toast.err { border-color: var(--red); }

/* ── Stats Banner ── */
.stats-banner {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  flex-shrink: 0;
}
.sb-stat {
  padding: 18px 28px;
  text-align: center;
  flex: 1;
}
.sb-val {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 5px;
}
.sb-val.sb-accent { color: var(--accent); }
.sb-val.sb-gold { color: var(--yellow); }
.sb-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.sb-sub {
  font-size: 9.5px;
  color: var(--muted);
  margin-top: 3px;
  opacity: 0.7;
}
.sb-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 860px) {
  .sidebar { width: 54px; }
  .brand-name,.brand-sub,.nav-item span,.nav-item .nav-badge,.nav-section-label { display: none; }
  .nav-item { justify-content: center; }
  .detail-right { display: none; }
  .dgrid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .contract-grid { grid-template-columns: 1fr; }
}
