:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --accent: #1663c7;
  --accent-dark: #0f4fa3;
  --good: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.status-strip {
  background: #eef2f7;
  border-bottom: 1px solid var(--line);
}

.system-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 10px 0;
}

.stat-item {
  min-width: 0;
  padding: 0 14px;
  border-left: 1px solid #d1d9e6;
}

.stat-item:first-child {
  border-left: 0;
  padding-left: 0;
}

.stat-item span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-item strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skeleton-stats {
  opacity: 0.65;
}

.brand {
  color: var(--text);
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--good);
}

.tool-panel,
.table-panel,
.summary-card,
.workflow-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-panel {
  margin-top: 18px;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
}

.panel-heading span,
.empty-state,
.summary-help,
.field-help {
  color: var(--muted);
}

.field-help {
  margin: 10px 0 0;
  font-size: 13px;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.workflow-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
}

.workflow-card:hover {
  border-color: #b7c7dc;
  text-decoration: none;
}

.workflow-card-primary {
  border-color: #b7c7dc;
  background: #f8fafc;
}

.workflow-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.workflow-card p {
  margin: 0;
  color: var(--muted);
}

.workflow-card strong {
  margin-top: auto;
  color: var(--accent);
}

.workflow-step {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.platform-profile {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid #b7c7dc;
  border-radius: 8px;
  background: #f8fafc;
}

.platform-profile h2 {
  margin: 4px 0;
  font-size: 26px;
  line-height: 1.2;
}

.platform-profile p {
  margin: 0 0 12px;
  color: var(--muted);
}

.profile-metrics,
.compare-identity-grid {
  display: grid;
  gap: 12px;
}

.profile-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.profile-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.2;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.identity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.identity-badge-active {
  border-color: #93b4df;
  background: #e8f1ff;
  color: #0f4fa3;
}

.family-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compact-badges {
  margin-top: 6px;
}

.compare-identity-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
}

.platform-mini-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.platform-mini-card strong,
.platform-mini-card span {
  display: block;
}

.platform-mini-card strong {
  margin: 4px 0;
  font-size: 20px;
}

.platform-mini-card > span:not(.summary-label) {
  margin-bottom: 10px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.search-row,
.compare-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.compare-row {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto auto;
  align-items: center;
}

.compare-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.preference-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.example-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.summary-card-featured {
  border-color: #b7c7dc;
  background: #f8fafc;
}

.summary-card-featured strong {
  font-size: 30px;
}

.executive-panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 0.8fr;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid #b7c7dc;
  border-radius: 8px;
  background: #f8fafc;
}

.executive-panel div {
  min-width: 0;
}

.executive-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.2;
}

.insight-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.insight-strip span {
  color: var(--muted);
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-help {
  font-size: 12px;
}

input,
button {
  min-height: 40px;
  border-radius: 6px;
  font: inherit;
}

input[type="search"],
input[type="text"] {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  background: #fff;
}

input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

.import-checkbox {
  margin-top: 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

button {
  padding: 8px 16px;
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.action-row {
  margin-top: 14px;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}

.rationale-cell {
  min-width: 210px;
}

.rationale-cell span,
.weak-guidance {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.rationale-list {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 13px;
}

.rationale-list li {
  margin: 2px 0;
}

.suggestion-panel {
  margin-top: 10px;
}

.suggestion-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.suggestion-item {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
}

.suggestion-button {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 400;
  text-align: left;
}

.suggestion-button:hover {
  background: #f8fafc;
}

.suggestion-item:hover {
  background: #f8fafc;
  text-decoration: none;
}

.suggestion-item span,
.suggestion-empty {
  color: var(--muted);
  font-size: 13px;
}

.suggestion-empty {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8edf5;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.badge-high {
  background: #dcfce7;
  color: #166534;
}

.badge-medium {
  background: #fef3c7;
  color: #92400e;
}

.badge-low {
  background: #fee2e2;
  color: #991b1b;
}

.info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.back-link {
  font-weight: 700;
}

.loading-indicator {
  display: none;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.htmx-request .loading-indicator,
.loading-indicator.htmx-request {
  display: block;
}

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

.uplift-positive {
  color: #166534;
  font-weight: 700;
}

.uplift-negative {
  color: #991b1b;
  font-weight: 700;
}

.uplift-bar-track {
  width: 120px;
  height: 7px;
  margin-top: 6px;
  overflow: hidden;
  background: #edf2f7;
  border-radius: 999px;
}

.uplift-bar {
  width: min(100%, calc(var(--bar-width) * 1%));
  height: 100%;
  border-radius: 999px;
}

.uplift-bar-positive {
  background: #86efac;
}

.uplift-bar-negative {
  background: #fca5a5;
}

.wide-cell {
  min-width: 260px;
}

.outlier-high {
  background: #f0fdf4;
}

.outlier-low {
  background: #fff1f2;
}

.prose {
  max-width: 860px;
}

.prose h2 {
  margin: 22px 0 8px;
  font-size: 18px;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p {
  margin: 0 0 12px;
}

.prose code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef2f7;
  color: #334155;
}

@media (max-width: 680px) {
  .topbar,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 16px;
  }

  .status-card {
    white-space: normal;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .compare-row,
  .compare-tool-grid,
  .compare-identity-grid,
  .detail-grid,
  .detail-list,
  .platform-profile,
  .profile-metrics,
  .summary-grid,
  .workflow-grid,
  .executive-panel,
  .system-stats,
  .suggestion-item {
    grid-template-columns: 1fr;
  }

  .insight-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .family-filter-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-item {
    border-left: 0;
    padding: 3px 0;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-panel {
    overflow-x: auto;
  }
}
