:root {
  --bg: #f7f2e8;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-strong: #fffaf2;
  --ink: #1e1f18;
  --muted: #65655c;
  --line: rgba(61, 59, 43, 0.14);
  --accent: #b45309;
  --accent-soft: #f4d7aa;
  --startup: #0b7285;
  --incumbent: #b02a37;
  --unknown: #867f70;
  --shadow: 0 20px 60px rgba(45, 31, 10, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(244, 215, 170, 0.85), transparent 32%),
    radial-gradient(circle at bottom right, rgba(176, 42, 55, 0.12), transparent 28%),
    linear-gradient(180deg, #fbf6ed 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1680px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr;
  gap: 1.5rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.eyebrow,
.section-label {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.95;
  margin-bottom: 0.9rem;
}

.hero-copy {
  max-width: 54rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
}

.hero-card,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  border-radius: 24px;
}

.hero-card {
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-stat-label,
.hero-card-copy {
  color: var(--muted);
}

.hero-stat {
  font-size: 2.2rem;
  margin: 0.2rem 0;
}

.tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab-button {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.75);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.tab-button:hover,
.tab-button.active {
  transform: translateY(-1px);
  background: var(--panel-strong);
  border-color: rgba(180, 83, 9, 0.35);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-grid,
.import-layout,
.map-layout {
  display: grid;
  gap: 1rem;
}

.panel-grid {
  grid-template-columns: repeat(12, 1fr);
}

.intro-card {
  grid-column: span 12;
  padding: 1.5rem;
}

.workbook-summary-card,
.memo-card,
.wide-section {
  grid-column: span 12;
}

.workbook-summary-card {
  padding: 0.95rem 1.15rem;
}

.research-sections {
  grid-column: span 12;
  display: grid;
  gap: 1rem;
}

.tech-card {
  grid-column: span 6;
  padding: 1.35rem;
  min-height: 210px;
}

.wide-card {
  grid-column: span 12;
}

.summary-strip,
.signal-grid,
.highlight-grid {
  display: grid;
  gap: 0.9rem;
}

.summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signal-grid,
.highlight-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 1rem;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.subtab-button {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.82);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.subtab-button.active {
  background: var(--panel-strong);
  color: var(--accent);
  border-color: rgba(180, 83, 9, 0.35);
}

.summary-label {
  margin-bottom: 0.18rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  color: var(--muted);
}

.summary-value {
  font-size: 1.2rem;
  margin: 0;
}

.research-card {
  padding: 1.05rem;
}

.research-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.sheet-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.research-meta {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

.table-note {
  margin-bottom: 0.8rem;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(180, 83, 9, 0.2);
  background: rgba(244, 215, 170, 0.22);
  line-height: 1.45;
  font-size: 0.92rem;
}

.sheet-table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.sheet-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.sheet-table th,
.sheet-table td {
  padding: 0.62rem 0.72rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: pre-line;
  line-height: 1.35;
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  background: #fff7eb;
  z-index: 1;
}

.sort-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sort-button.active {
  color: var(--accent);
}

.sort-marker {
  color: var(--muted);
  font-size: 0.9rem;
}

.sheet-table tbody tr:nth-child(even) {
  background: rgba(255, 248, 236, 0.55);
}

.signal-card,
.highlight-card {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 243, 0.68);
}

.tech-visual {
  margin-top: 0.75rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fffdf8;
}

.tech-visual-body {
  padding: 0.55rem;
}

.tech-visual-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.45rem;
}

.expand-visual-button {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.92);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.tech-visual-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

.tech-visual img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.image-modal.open {
  display: block;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 18, 0.7);
}

.image-modal-dialog {
  position: relative;
  width: min(1400px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  margin: 1rem auto;
  background: rgba(255, 251, 245, 0.98);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.image-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.image-modal-body {
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1rem;
  background: #f7f3eb;
}

.image-modal-body img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
}

.buyer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.75fr);
  gap: 1rem;
}

.pdf-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.55fr) minmax(0, 1.85fr);
  gap: 1rem;
}

.buyer-detail-card,
.buyer-sidebar,
.buyer-selector-card,
.pdf-sidebar,
.pdf-viewer-card {
  padding: 1.35rem;
}

.buyer-lead {
  color: var(--muted);
  line-height: 1.65;
}

.buyer-meta,
.buyer-list,
.source-list {
  display: grid;
  gap: 0.75rem;
}

.buyer-meta {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 1rem 0 1.2rem;
}

.buyer-metric {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 249, 239, 0.7);
}

.buyer-metric p:last-child,
.buyer-list p:last-child {
  margin-bottom: 0;
}

.buyer-section-title {
  margin: 1.2rem 0 0.65rem;
  font-size: 1.05rem;
}

.buyer-list-card,
.source-card {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 243, 0.68);
}

.source-card a,
.buyer-detail-card a {
  color: var(--accent);
}

.buyer-side-grid {
  display: grid;
  gap: 0.85rem;
}

.pdf-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pdf-item-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.82);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  cursor: pointer;
}

.pdf-item-button.active {
  border-color: rgba(180, 83, 9, 0.35);
  background: var(--panel-strong);
}

.pdf-item-button p:last-child {
  margin-bottom: 0;
}

.pdf-item-button .file-kind {
  display: inline-block;
  margin-bottom: 0.3rem;
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pdf-frame {
  margin-top: 0.75rem;
  min-height: 80vh;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

#pdf-frame {
  width: 100%;
  min-height: 80vh;
  border: 0;
  display: block;
}

.sheet-viewer {
  margin-top: 1rem;
  display: none;
}

.sheet-viewer.active {
  display: block;
}

.pdf-frame.hidden {
  display: none;
}

.role-pill {
  display: inline-block;
  margin: 0.2rem 0.35rem 0.2rem 0;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.88);
  color: var(--muted);
}

.signal-card p:last-child,
.highlight-card p:last-child {
  margin-bottom: 0;
}

.map-layout {
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  align-items: start;
}

.map-card,
.detail-card,
.import-card,
.table-card {
  padding: 1.35rem;
}

.map-toolbar,
.table-header,
.action-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.filter-wrap,
.field-block {
  display: grid;
  gap: 0.45rem;
}

.filter-wrap span,
.field-block span,
.helper-copy,
.status-copy,
th {
  color: var(--muted);
}

.map-frame {
  position: relative;
  margin-top: 1rem;
  border-radius: 22px;
  overflow: hidden;
  min-height: 520px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 20%, rgba(244, 215, 170, 0.28), transparent 22%),
    linear-gradient(180deg, rgba(10, 83, 100, 0.07) 0%, rgba(10, 83, 100, 0.15) 100%);
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 62px 62px;
}

#company-map {
  position: relative;
  width: 100%;
  height: 520px;
  display: block;
}

.legend {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  margin-right: 0.45rem;
}

.startup-dot {
  background: var(--startup);
}

.incumbent-dot {
  background: var(--incumbent);
}

.unknown-dot {
  background: var(--unknown);
}

.detail-card {
  min-height: 100%;
}

.detail-card a {
  color: var(--accent);
}

.import-layout {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: start;
}

.import-controls {
  display: grid;
  gap: 1rem;
}

textarea,
select,
input[type="file"] {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  padding: 0.9rem 1rem;
}

textarea {
  resize: vertical;
  min-height: 250px;
}

.action-button,
.ghost-button {
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  border: 1px solid var(--line);
  cursor: pointer;
}

.action-button {
  background: var(--accent);
  color: #fff8f0;
}

.ghost-button {
  background: transparent;
}

.table-wrap {
  overflow: auto;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.company-node {
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}

.company-node:hover,
.company-node.active {
  transform: scale(1.08);
}

.company-label {
  font-size: 13px;
  fill: rgba(30, 31, 24, 0.84);
}

.helper-copy,
.status-copy {
  font-size: 0.95rem;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .hero,
  .buyer-layout,
  .pdf-layout,
  .map-layout,
  .import-layout {
    grid-template-columns: 1fr;
  }

  .tech-card {
    grid-column: span 12;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }
}
