:root {
  color-scheme: dark;
  --bg: #0a0d0c;
  --panel: #111614;
  --panel-2: #171d1a;
  --line: #2b3430;
  --line-strong: #46534d;
  --text: #f2f4f1;
  --muted: #9ba59f;
  --green: #76e2a8;
  --green-ink: #062416;
  --blue: #8bc5ff;
  --coral: #ff957e;
  --amber: #efc466;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); }
body, button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
button { color: inherit; }

.public-header, .workspace-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 12, .96);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 750; }
.brand-mark { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--green); border-radius: 5px; color: var(--green); }
.public-header nav { display: flex; gap: 28px; color: var(--muted); font-size: 13px; }
.public-header nav a:hover, .text-link:hover { color: var(--text); }
.header-action {
  display: inline-flex;
  min-width: 72px;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}
.header-action[data-auth-pending] { visibility: hidden; }
.header-action.user-session { min-width: 0; color: var(--text); }
.user-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-display-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.home-hero {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(520px, 1.1fr);
  align-items: center;
  gap: 8vw;
  width: min(100%, 1440px);
  min-height: calc(100svh - 128px);
  margin: auto;
  padding: 72px 5vw 60px;
}
.eyebrow { margin: 0 0 18px; color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: 0; }
.home-hero h1 { margin: 0; font-size: 76px; line-height: 1.02; letter-spacing: 0; }
.home-hero h1 span { color: var(--green); }
.hero-lede { max-width: 570px; margin: 28px 0 0; color: #b6beb9; font-size: 17px; line-height: 1.8; }
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 34px; }
.button, button.primary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 11px 17px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}
.button.primary, button.primary { background: var(--green); color: var(--green-ink); }
.button.primary:hover, button.primary:hover { background: #9af0bf; }
.text-link { color: var(--blue); font-size: 13px; }

.hero-system { border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.system-head { display: flex; justify-content: space-between; padding: 16px 0; color: var(--muted); font-size: 12px; }
.system-head b { color: var(--green); font-weight: 700; }
.system-flow { margin: 0; padding: 0; list-style: none; }
.system-flow li { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 92px; border-top: 1px solid var(--line); }
.system-flow li > span { color: var(--green); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.system-flow strong, .system-flow small { display: block; }
.system-flow strong { margin-bottom: 6px; font-size: 16px; }
.system-flow small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.system-flow i { color: var(--blue); font-size: 11px; font-style: normal; }
.system-note { margin: 0; padding: 16px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.signal-band { display: flex; justify-content: space-around; gap: 20px; padding: 20px 5vw; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: #b4bdb8; font-size: 12px; }

.method-section, .boundary-section { width: min(100%, 1440px); margin: auto; padding: 112px 5vw; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.section-title h2, .boundary-section h2 { margin: 0; font-size: 44px; line-height: 1.15; letter-spacing: 0; }
.method-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 70px; }
.method-grid article { border-top: 1px solid var(--line-strong); padding-top: 18px; }
.method-grid article > span { color: var(--coral); font-size: 12px; }
.method-grid h3 { margin: 34px 0 12px; font-size: 18px; }
.method-grid p, .boundary-section > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.boundary-section { display: grid; grid-template-columns: 1fr 1fr; gap: 9vw; border-top: 1px solid var(--line); }
.boundary-section > p { align-self: end; max-width: 570px; font-size: 16px; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 5vw; border-top: 1px solid var(--line); color: #7f8a84; font-size: 11px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a:hover { color: var(--text); }

.workspace-header { padding: 0 28px; }
.workspace-nav { display: flex; align-items: center; gap: 22px; }
.workspace-nav a { color: var(--muted); font-size: 13px; }
.workspace-nav a.active { color: var(--green); }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-identity { display: flex; min-width: 0; align-items: center; gap: 9px; }
.user-name { max-width: 180px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button, .secondary-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}
.icon-button { width: 36px; padding: 0; font-size: 18px; }
.secondary-button { padding: 8px 12px; }
.icon-button:hover, .secondary-button:hover { border-color: var(--green); }

.auth-page { display: grid; min-height: 100svh; grid-template-columns: 1fr minmax(380px, 520px); }
.auth-context { display: flex; flex-direction: column; justify-content: space-between; padding: 48px 7vw; border-right: 1px solid var(--line); }
.auth-context h1 { max-width: 700px; margin: 80px 0 20px; font-size: 56px; line-height: 1.08; letter-spacing: 0; }
.auth-context h1 span { color: var(--green); }
.auth-context > div > p { max-width: 580px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.auth-points { display: flex; gap: 24px; color: #85918a; font-size: 11px; }
.auth-panel { display: grid; align-content: center; padding: 48px 56px; background: var(--panel); }
.auth-panel h2 { margin: 0 0 8px; font-size: 28px; }
.auth-panel > p { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 24px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; }
.segmented button { min-height: 38px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; }
.segmented button.active { background: var(--panel-2); color: var(--text); }
.auth-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field span { color: #b8c1bc; font-size: 12px; }
.field input, .filter-control select, .filter-control input {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #0d1210;
  color: var(--text);
  padding: 10px 12px;
}
.form-message { min-height: 20px; margin: 0; color: var(--coral); font-size: 12px; }
.auth-back { margin-top: 24px; color: var(--blue); font-size: 12px; }

.workspace { min-height: calc(100svh - 68px); padding: 28px; }
.workspace-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.workspace-title h1 { margin: 0 0 6px; font-size: 30px; }
.workspace-title p { margin: 0; color: var(--muted); font-size: 13px; }
.batch-meta { color: #829089; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 460px); gap: 20px; align-items: start; }
.workspace-grid.list-only { grid-template-columns: 1fr; }
.opportunity-main, .detail-panel { min-width: 0; }
.filter-bar { display: grid; grid-template-columns: minmax(160px, 1fr) 160px 160px auto; gap: 10px; margin-bottom: 14px; }
.filter-control { display: grid; gap: 6px; }
.filter-control span { color: var(--muted); font-size: 11px; }
.filter-control input, .filter-control select { min-height: 39px; padding: 8px 10px; font-size: 12px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; }
.summary-item { min-width: 0; padding: 14px; border-left: 1px solid var(--line); }
.summary-item:first-child { border-left: 0; }
.summary-item span, .summary-item small { display: block; color: var(--muted); font-size: 10px; }
.summary-item strong { display: block; margin: 5px 0; overflow: hidden; font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
.notice { margin-bottom: 14px; border-left: 3px solid var(--amber); background: #1e1a10; padding: 12px 14px; color: #dfca9b; font-size: 12px; line-height: 1.6; }
.notice.error { border-left-color: var(--coral); background: #231310; color: #ffc0b2; }
.opportunity-list { border-top: 1px solid var(--line-strong); }
.opportunity-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) minmax(120px, .8fr) repeat(3, minmax(76px, .55fr)) 28px;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 92px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 14px 8px;
  cursor: pointer;
  text-align: left;
}
.opportunity-row:hover, .opportunity-row.selected { background: #131a17; }
.opportunity-row strong, .opportunity-row small { display: block; }
.symbol { font-size: 18px; }
.row-subtitle { margin-top: 6px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.state-badge { display: inline-flex; width: fit-content; border: 1px solid var(--line-strong); border-radius: 99px; padding: 5px 8px; color: var(--amber); font-size: 10px; }
.state-badge.ready { border-color: #3c8d62; color: var(--green); }
.metric-value { font-size: 14px; }
.metric-label { margin-top: 5px; color: var(--muted); font-size: 10px; }
.row-arrow { color: var(--blue); font-size: 18px; }
.empty-state, .loading-state { display: grid; min-height: 330px; place-content: center; justify-items: center; padding: 40px; text-align: center; }
.empty-state strong, .loading-state strong { font-size: 20px; }
.empty-state p, .loading-state p { max-width: 480px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.loader { width: 22px; height: 22px; margin-bottom: 18px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: 11px; }
.detail-panel { position: sticky; top: 88px; max-height: calc(100svh - 108px); overflow: auto; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); }
.detail-head { padding: 20px; border-bottom: 1px solid var(--line); }
.detail-back { display: none; margin-bottom: 16px; color: var(--blue); }
.detail-head h2 { margin: 12px 0 6px; font-size: 24px; }
.detail-head p { margin: 0; color: var(--muted); font-size: 11px; }
.detail-section { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.detail-section h3 { margin: 0 0 14px; font-size: 13px; }
.detail-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.detail-kpis div { background: var(--panel); padding: 13px; }
.detail-kpis span, .detail-kpis small { display: block; color: var(--muted); font-size: 10px; }
.detail-kpis strong { display: block; margin: 6px 0; font-size: 18px; }
.reason-list, .evidence-list, .timeline { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.reason-list li { border-left: 2px solid var(--amber); padding: 7px 10px; background: #1c1911; color: #dac796; font-size: 11px; line-height: 1.6; }
.evidence-list li, .timeline li { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 11px; }
.evidence-list span, .timeline span { color: var(--muted); }
.evidence-list b, .timeline b { overflow-wrap: anywhere; text-align: right; }
.disclaimer { color: #849089; font-size: 10px; line-height: 1.7; }
.noscript { padding: 30px; color: var(--coral); }

@media (max-width: 980px) {
  .home-hero { grid-template-columns: 1fr; gap: 64px; min-height: auto; padding-top: 82px; }
  .home-hero h1 { font-size: 64px; }
  .method-section, .boundary-section { padding-top: 90px; padding-bottom: 90px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-context { min-height: 340px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-context h1 { margin-top: 42px; font-size: 44px; }
  .auth-panel { min-height: 620px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
}

@media (max-width: 720px) {
  .public-header, .workspace-header { min-height: 62px; padding: 0 18px; }
  .public-header nav { display: none; }
  .user-display-name { max-width: 92px; }
  .home-hero { padding: 60px 20px 50px; }
  .home-hero h1 { font-size: 48px; }
  .hero-lede { font-size: 15px; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 16px; }
  .signal-band { align-items: flex-start; flex-direction: column; padding: 18px 20px; }
  .method-section, .boundary-section { padding: 72px 20px; }
  .section-title, .boundary-section { display: block; }
  .section-title h2, .boundary-section h2 { font-size: 34px; }
  .method-grid { grid-template-columns: 1fr; gap: 34px; margin-top: 48px; }
  .boundary-section > p { margin-top: 36px; }
  footer { align-items: flex-start; flex-direction: column; padding: 22px 20px; }
  .workspace-nav a:not(.active) { display: none; }
  .user-name { display: none; }
  .workspace { padding: 20px 14px 50px; }
  .workspace-title { align-items: flex-start; flex-direction: column; }
  .batch-meta { text-align: left; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-control:first-child { grid-column: 1 / -1; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-item:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .summary-item:nth-child(4) { border-top: 1px solid var(--line); }
  .opportunity-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; min-height: 0; padding: 16px 5px; }
  .opportunity-row > div:nth-child(n+3):nth-child(-n+5) { display: none; }
  .row-arrow { grid-column: 2; grid-row: 1 / span 2; }
  .detail-panel { border: 0; background: transparent; }
  .detail-back { display: inline-flex; }
  .detail-head, .detail-section { padding-right: 4px; padding-left: 4px; }
  .auth-context { min-height: 300px; padding: 30px 24px; }
  .auth-context h1 { margin-top: 40px; font-size: 36px; }
  .auth-points { flex-wrap: wrap; gap: 10px 18px; }
  .auth-panel { min-height: 580px; padding: 40px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .loader { animation: none; }
}
