:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --text: #172033;
  --muted: #5b6578;
  --line: #e5e7eb;
  --line-strong: #d8dee8;
  --accent: #166534;
  --warning-bg: #fff7ed;
  --warning-text: #9a3412;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Apple SD Gothic Neo", sans-serif;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel);
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.page-header p,
.detail-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.source-files {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.caveat-block {
  margin: 16px 24px 0;
  padding: 12px 14px;
  color: #334155;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  font-size: 13px;
  line-height: 1.45;
}

.caveat-block p + p {
  margin-top: 6px;
}

.metric-tabs-panel {
  margin: 16px 24px 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.metric-tabs-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.metric-tabs-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

#active-metric-label {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.metric-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-tab {
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.metric-tab:hover {
  background: #e2e8f0;
}

.metric-tab.active,
.metric-tab[aria-selected="true"] {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 420px;
  gap: 16px;
  align-items: start;
  padding: 16px 24px 24px;
}

.map-panel {
  min-width: 0;
  background: var(--bg);
}

.detail-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  padding: 12px;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

#selection-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button:hover {
  background: #e2e8f0;
}

.detail-heading {
  margin-bottom: 12px;
}

.detail-heading h2 {
  font-size: 20px;
  line-height: 1.25;
}

.badge-row {
  margin-top: 10px;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--warning-text);
  background: var(--warning-bg);
  border: 1px solid #fed7aa;
}

.badge-muted {
  color: var(--muted);
  background: #f8fafc;
  border-color: var(--line);
}

.detail-section h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 6px;
  font-size: 14px;
}

.section-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  color: #334155;
  background: #e2e8f0;
  font-size: 11px;
  font-weight: 800;
  cursor: help;
}

.cell-help {
  width: 14px;
  height: 14px;
  margin-left: 4px;
  font-size: 10px;
  vertical-align: 1px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}

.detail-table th {
  text-align: left;
  font-weight: 700;
}

.detail-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

.detail-table td:first-child {
  color: var(--muted);
}

.detail-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
  }

  .source-files {
    align-items: flex-start;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .caveat-block {
    margin: 12px 16px 0;
  }

  .metric-tabs-panel {
    margin: 12px 16px 0;
  }

  .metric-tabs-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  #active-metric-label {
    text-align: left;
  }

  .metric-tab {
    padding: 7px 10px;
    font-size: 12px;
  }

  .app-shell {
    padding: 12px 16px 18px;
  }

  h1 {
    font-size: 19px;
  }
}
