:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header { margin-bottom: 2rem; }

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.timestamp {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ---- Executive Insights ---- */

.insights-block {
  background: rgba(88, 166, 255, 0.06);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.insights-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.insights-block ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.4rem 2rem;
}

.insights-block li {
  font-size: 0.875rem;
  color: var(--text);
  padding-left: 1rem;
  position: relative;
}

.insights-block li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ---- Section headers ---- */

.section-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

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

.card-category {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ---- Tier labels ---- */

.tier-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.tier-sub {
  font-weight: 400;
  font-size: 0.75rem;
  text-transform: none;
}

/* ---- Badges ---- */

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-full {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-partial {
  background: rgba(210, 153, 34, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-opaque {
  background: rgba(248, 81, 73, 0.1);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

/* ---- Metrics grid ---- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.metric {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.metric.positive .metric-value { color: var(--green); }
.metric.negative .metric-value { color: var(--red); }

.metric-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Metrics row (side by side groups) ---- */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.metrics-group {
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.metrics-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* ---- Mini bars ---- */

.mini-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}

.mini-bar-label {
  flex: 0 0 auto;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.mini-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.mini-bar-value {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3rem;
  text-align: right;
}

.mini-stat {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

.hint {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ---- Concentration panel ---- */

.concentration-panel {
  border-color: rgba(248, 81, 73, 0.2);
}

.concentration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.conc-metric {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.conc-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.conc-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.25rem;
}

.conc-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ---- Proportion bar ---- */

.proportion-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.5rem;
  gap: 1px;
}

.proportion-seg {
  transition: width 0.3s;
}

.proportion-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.proportion-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.proportion-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ---- Tables ---- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.data-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Entity descriptions ---- */

.entity-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 400;
  display: block;
  margin-top: 0.1rem;
}

/* ---- Section titles inside cards ---- */

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1rem 0 0.5rem;
}

/* ---- Expand toggles ---- */

.expand-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

.expand-toggle:hover {
  background: rgba(88, 166, 255, 0.1);
}

/* ---- Limited-data cards ---- */

.limited-info {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.limited-info p { margin-bottom: 0.5rem; }

.limited-info ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.limited-info ul li {
  margin-bottom: 0.35rem;
}

.limited-info .note {
  font-style: italic;
  font-size: 0.8rem;
  opacity: 0.8;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---- App websites ---- */

.app-websites {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.app-website-link {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}

.app-website-link:hover {
  background: rgba(88, 166, 255, 0.1);
}

/* ---- Footer ---- */

footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

footer h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

footer ul {
  list-style: none;
  margin-bottom: 1rem;
}

footer li { margin-bottom: 0.25rem; }

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

.methodology {
  font-size: 0.8rem;
  line-height: 1.5;
  opacity: 0.8;
}

/* ---- Registry filters ---- */

.reg-filter-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  appearance: auto;
}

.reg-filter-select:hover {
  border-color: var(--accent);
}

/* ---- Section nav ---- */

html { scroll-behavior: smooth; }

.section-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.section-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.section-nav a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.05);
}

/* ---- Signal blocks (history section) ---- */
.signal-block {
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.signal-warn {
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid rgba(210, 153, 34, 0.35);
  color: var(--yellow);
}
.signal-ok {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--green);
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  .container { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics-row { grid-template-columns: 1fr; }
  .concentration-grid { grid-template-columns: repeat(2, 1fr); }
  .insights-block ul { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
  .metric-value { font-size: 1rem; }
  .data-table { font-size: 0.8rem; }
  .data-table th,
  .data-table td { padding: 0.35rem 0.5rem; }
}
