:root {
  --gp-blue: #1478ff;
  --gp-blue-soft: #e8f1ff;
  --bg: #fafbfc;
  --surface: #ffffff;
  --border: #e4e7eb;
  --text: #111418;
  --muted: #6b7280;
  --amber: #d97706;
  --red: #dc2626;
  --green: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(17, 20, 24, 0.04), 0 1px 3px rgba(17, 20, 24, 0.06);
  --mono: ui-monospace, SFMono-Regular, "Menlo", monospace;
  --sans: "Helvetica Now Display", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--gp-blue);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-nav {
  display: flex;
  gap: 4px;
}

.app-nav a {
  padding: 8px 14px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
}

.app-nav a:hover {
  background: var(--gp-blue-soft);
  color: var(--gp-blue);
}

.app-nav a.active {
  background: var(--gp-blue-soft);
  color: var(--gp-blue);
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.currency-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--gp-blue);
  color: var(--gp-blue);
}

.export-menu {
  position: relative;
}

.export-dropdown {
  position: absolute;
  right: 0;
  top: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  min-width: 260px;
  padding: 6px;
  z-index: 20;
}

.export-dropdown a {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
}

.export-dropdown a:hover {
  background: var(--gp-blue-soft);
  color: var(--gp-blue);
}

.hidden {
  display: none;
}

.view-root {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.loading {
  padding: 60px;
  text-align: center;
  color: var(--muted);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  margin-top: 6px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 20px 0 10px;
  font-weight: 600;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.company-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: border-color 0.12s;
}

.company-tile:hover {
  border-color: var(--gp-blue);
}

.company-tile.stale {
  border-color: #fde68a;
  background: #fffbeb;
}

.company-tile.very-stale {
  border-color: #fecaca;
  background: #fef2f2;
}

.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tile-name {
  font-weight: 600;
  font-size: 15px;
}

.tile-period {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tile-metric {
  font-size: 20px;
  font-weight: 600;
  color: var(--gp-blue);
  font-variant-numeric: tabular-nums;
}

.tile-metric-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tile-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.tile-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.confidence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 6px;
}

.confidence-dot.low {
  background: var(--amber);
}

.confidence-dot.verylow {
  background: var(--red);
}

.company-detail h1 {
  font-size: 28px;
  margin: 0 0 4px 0;
}

.company-detail .meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 200px;
}

table.ptable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.ptable th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

table.ptable td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

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

.narrative-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.narrative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.narrative-card .when {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.narrative-card .body {
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.narrative-card .notes {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.company-specific {
  font-size: 12px;
}

.company-specific dt {
  color: var(--muted);
  margin-top: 4px;
}

.company-specific dd {
  margin: 0 0 2px 0;
  font-variant-numeric: tabular-nums;
}

.explorer-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.explorer-controls label {
  font-size: 13px;
  color: var(--muted);
}

.explorer-controls select {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.explorer-chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  height: 440px;
  box-shadow: var(--shadow);
}

.reports-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.report-item:hover {
  border-color: var(--gp-blue);
}

.report-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 12px;
}

.app-footer {
  padding: 16px 24px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.error-banner {
  padding: 14px 18px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--red);
  margin-bottom: 16px;
}

@media (max-width: 820px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
  }
}
