:root {
  --ink: #12211b;
  --muted: #617069;
  --paper: #f6f7f2;
  --surface: rgba(255, 255, 255, 0.82);
  --line: #dfe5dd;
  --green: #167453;
  --green-dark: #0d533b;
  --lime: #c9f55a;
  --orange: #ff7a45;
  --shadow: 0 22px 70px rgba(20, 52, 38, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 40, 32, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 40, 32, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: Aptos, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

.page-glow {
  position: fixed;
  z-index: -1;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
}

.page-glow-one { top: -16rem; right: -8rem; background: var(--lime); }
.page-glow-two { top: 38rem; left: -20rem; background: #62c6ff; }

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  color: white;
  background: var(--ink);
  border-radius: 11px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #eab308;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.12);
}

.connection-pill[data-status="connected"] .status-dot {
  background: #17a56f;
  box-shadow: 0 0 0 4px rgba(23, 165, 111, 0.12);
}

.connection-pill[data-status="error"] .status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.hero { padding: 86px 0 105px; }

.eyebrow {
  margin-bottom: 16px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(56px, 8vw, 103px);
  line-height: 0.92;
  letter-spacing: -0.065em;
}

h1 span { color: var(--green); }

.hero-copy {
  max-width: 690px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.data-path {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 45px;
}

.path-node {
  display: flex;
  align-items: center;
  min-width: 202px;
  gap: 12px;
  padding: 12px 15px 12px 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(20, 52, 38, 0.04);
}

.node-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  color: var(--green);
  background: #e9f3ed;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.path-node strong,
.path-node small { display: block; }
.path-node strong { font-size: 13px; }
.path-node small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.accent-node { color: white; background: var(--green); border-color: var(--green); }
.accent-node .node-icon { color: var(--ink); background: var(--lime); }
.accent-node small { color: rgba(255, 255, 255, 0.7); }
.path-arrow { color: #aeb9b3; font-size: 20px; }

.source-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 11px;
}

.source-line span {
  padding: 5px 8px;
  color: var(--green-dark);
  background: #dff1e7;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.86em;
}

.dashboard {
  margin-bottom: 50px;
  padding: 40px;
  background: var(--surface);
  border: 1px solid rgba(216, 224, 216, 0.85);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading .eyebrow { margin-bottom: 9px; }
h2 { margin: 0; font-size: clamp(30px, 4vw, 45px); letter-spacing: -0.045em; }

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  color: white;
  background: var(--ink);
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.refresh-button:hover { background: var(--green); }
.refresh-button:disabled { cursor: wait; opacity: 0.65; }
.refresh-button.is-loading span { animation: spin 0.7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr 1.2fr;
  gap: 12px;
  margin: 30px 0 26px;
}

.stat-card {
  min-height: 128px;
  padding: 20px;
  background: #f7f9f6;
  border: 1px solid var(--line);
  border-radius: 17px;
}

.stat-card span,
.stat-card small,
.stat-card strong { display: block; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.stat-card strong { margin: 15px 0 4px; font-size: 27px; letter-spacing: -0.045em; }
.stat-card small { color: var(--muted); font-size: 11px; }
.protocol-stat { color: white; background: var(--green); border-color: var(--green); }
.protocol-stat .stat-label, .protocol-stat small { color: rgba(255, 255, 255, 0.7); }
.protocol-stat strong { color: var(--lime); font-family: "JetBrains Mono", monospace; font-size: 22px; }

.content-grid {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 19px;
  overflow: hidden;
}

.company-panel { padding: 16px; background: #f2f5f1; border-right: 1px solid var(--line); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.search-box span { color: var(--muted); font-size: 18px; }
.search-box input { width: 100%; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 11px; }
.search-box input::placeholder { color: #95a19b; }
.company-list { display: grid; gap: 8px; margin-top: 13px; }

.company-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 15px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.company-card:hover { transform: translateY(-1px); background: white; border-color: #cbd5ce; }
.company-card.is-active { color: white; background: var(--ink); border-color: var(--ink); }
.company-card span, .company-card strong { display: block; }
.company-id { margin-bottom: 7px; color: var(--green); font-family: "JetBrains Mono", monospace; font-size: 9px; text-transform: uppercase; }
.company-card.is-active .company-id { color: var(--lime); }
.company-card strong { padding-right: 14px; font-size: 13px; line-height: 1.25; }
.company-sector { min-height: 29px; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.company-card.is-active .company-sector { color: rgba(255, 255, 255, 0.62); }
.purchase-badge { margin-top: 10px; font-size: 10px; font-weight: 700; }
.purchase-badge b { float: right; color: var(--green); }
.company-card.is-active .purchase-badge b { color: var(--lime); }

.detail-panel { min-width: 0; padding: 30px; background: white; }
.detail-header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.document-label { color: var(--green); font-family: "JetBrains Mono", monospace; font-size: 9px; text-transform: uppercase; }
.detail-header h3 { margin: 8px 0 3px; font-size: 26px; letter-spacing: -0.035em; }
.detail-header p { margin: 0; color: var(--muted); font-size: 12px; }
.document-total { flex: 0 0 auto; text-align: right; }
.document-total span { display: block; color: var(--muted); font-size: 10px; }
.document-total strong { display: block; margin-top: 5px; color: var(--green); font-size: 20px; }

.document-meta { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 15px; padding: 18px 0; }
.document-meta span { min-width: 0; font-size: 11px; font-weight: 600; }
.document-meta small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; font-weight: 500; text-transform: uppercase; }
.document-meta code { display: block; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { padding: 10px 8px; color: var(--muted); text-align: left; border-block: 1px solid var(--line); font-size: 8px; letter-spacing: 0.06em; text-transform: uppercase; }
td { padding: 13px 8px; vertical-align: top; border-bottom: 1px solid #edf0ec; }
td strong, td small { display: block; }
td strong { font-size: 10px; }
td small { max-width: 250px; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.4; }
td code { white-space: nowrap; }
td.amount { color: var(--green-dark); text-align: right; white-space: nowrap; font-weight: 700; }
th:last-child { text-align: right; }

.raw-json { margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.raw-json summary { padding: 12px 14px; cursor: pointer; color: var(--green-dark); background: #f5f8f5; font-size: 10px; font-weight: 700; list-style: none; }
.raw-json summary::-webkit-details-marker { display: none; }
.raw-json summary span { float: right; font-size: 15px; font-weight: 400; }
.raw-json[open] summary span { transform: rotate(45deg); }
.raw-json pre { max-height: 360px; margin: 0; padding: 18px; overflow: auto; color: #cae5d8; background: #13221c; font-family: "JetBrains Mono", monospace; font-size: 9px; line-height: 1.65; }

.empty-state { display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 500px; padding: 40px; color: var(--muted); text-align: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 18px; color: var(--green); background: #edf5f0; border-radius: 17px; font-family: "JetBrains Mono", monospace; }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); }
.empty-state p { max-width: 300px; margin: 0; font-size: 12px; line-height: 1.6; }
.error-state .empty-icon { color: #b42318; background: #fef3f2; }
.updated-line { margin: 13px 2px 0; color: var(--muted); font-size: 9px; text-align: right; }

.loading-card { height: 104px; padding: 15px; background: rgba(255, 255, 255, 0.65); border-radius: 12px; }
.loading-card span, .detail-loading span { display: block; height: 8px; margin-bottom: 10px; background: linear-gradient(90deg, #e8ece8 25%, #f7f9f7 50%, #e8ece8 75%); background-size: 200% 100%; border-radius: 5px; animation: shimmer 1.3s infinite; }
.loading-card span:nth-child(1) { width: 34%; }
.loading-card span:nth-child(2) { width: 75%; }
.loading-card span:nth-child(3) { width: 55%; }
.detail-loading { padding: 12px; }
.detail-loading span { height: 18px; margin-bottom: 22px; }
.detail-loading span:nth-child(1) { width: 42%; }
.detail-loading span:nth-child(2) { width: 85%; }
.detail-loading span:nth-child(3) { width: 70%; }
.detail-loading span:nth-child(4) { width: 92%; }

@keyframes shimmer { to { background-position: -200% 0; } }

.no-results { display: grid; gap: 4px; padding: 30px 14px; color: var(--muted); text-align: center; font-size: 10px; }
.no-results strong { color: var(--ink); font-size: 12px; }
.error-copy span { color: #b42318; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 0 0 35px;
  color: var(--muted);
  font-size: 10px;
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 220px minmax(0, 1fr); }
  .dashboard { padding: 28px; }
  .data-path { align-items: stretch; }
  .path-node { min-width: 0; flex: 1; }
}

@media (max-width: 700px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }
  .site-header { padding-top: 14px; }
  .brand > span:last-child { display: none; }
  .hero { padding: 55px 0 70px; }
  h1 { font-size: clamp(49px, 16vw, 78px); }
  .hero-copy { font-size: 15px; }
  .data-path { display: grid; grid-template-columns: 1fr; }
  .path-arrow { display: none; }
  .source-line { align-items: flex-start; flex-direction: column; }
  .source-line code { max-width: 100%; overflow-wrap: anywhere; }
  .dashboard { padding: 20px 14px; border-radius: 20px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 114px; padding: 16px; }
  .stat-card strong { font-size: 21px; }
  .content-grid { display: block; }
  .company-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .company-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-panel { padding: 20px 14px; }
  .detail-header { align-items: flex-start; flex-direction: column; }
  .document-total { text-align: left; }
  .document-meta { grid-template-columns: 1fr 1fr; }
  .document-meta span:last-child { grid-column: 1 / -1; }
  footer { gap: 10px; flex-direction: column; }
}

@media (max-width: 430px) {
  .connection-pill { padding: 8px 10px; font-size: 10px; }
  .stats { grid-template-columns: 1fr; }
  .company-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
