:root {
  --bg: #f3efe3;
  --surface: rgba(255, 252, 245, 0.8);
  --surface-strong: #fffaf0;
  --surface-muted: #e7deca;
  --ink: #1c1b18;
  --ink-soft: #5f5a52;
  --line: rgba(39, 34, 28, 0.14);
  --accent: #bf5b3d;
  --accent-strong: #8f351a;
  --accent-soft: #f0c3a7;
  --success: #285b47;
  --shadow: 0 18px 40px rgba(71, 47, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(191, 91, 61, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(40, 91, 71, 0.12), transparent 24%),
    linear-gradient(180deg, #f6f1e7 0%, #ebe2d2 100%);
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

button,
input,
select {
  font: inherit;
}

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

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.nav-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.nav-link.active {
  background: var(--ink);
  color: white;
  border-color: transparent;
}

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

.hero h1,
.panel-header h2,
.card-header h3,
.detail-header h3 {
  font-family: "Times New Roman", Georgia, serif;
  letter-spacing: -0.03em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
}

.lede {
  max-width: 58rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}

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

.hero-card {
  min-width: 260px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(40, 91, 71, 0.12);
}

.layout {
  display: grid;
  gap: 22px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.panel {
  padding: 22px;
}

.panel-header,
.card-header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.panel-header h2,
.card-header h3,
.detail-header h3 {
  margin: 0;
}

.stats-grid,
.grid-two {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0;
}

.stats-grid.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 0;
  gap: 12px;
}

.stats-grid.compact .metric-card {
  padding: 14px 14px 12px;
  border-radius: 18px;
}

.stats-grid.compact .metric-card strong {
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  margin: 4px 0 6px;
}

.stats-grid.compact .metric-card p,
.stats-grid.compact .metric-card span {
  font-size: 0.8rem;
}

.grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  padding: 18px;
  background: var(--surface-strong);
}

.metric-card p,
.metric-card span,
.bar-meta span,
.result-card p,
.detail-pane p,
.mini-meta span,
.table-row p {
  color: var(--ink-soft);
}

.metric-card p,
.metric-card span,
.metric-card strong {
  display: block;
}

.metric-card strong {
  font-size: clamp(1.2rem, 2.1vw, 1.8rem);
  line-height: 1.1;
  margin: 6px 0 8px;
  overflow-wrap: anywhere;
}

.overview-copy {
  margin: 10px 0 0;
  max-width: 72ch;
  color: var(--ink-soft);
  line-height: 1.6;
}

.insight-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.insight-card.muted {
  background: rgba(231, 222, 202, 0.45);
}

.insight-card p,
.insight-card span {
  color: var(--ink-soft);
}

.insight-card p,
.insight-card strong,
.insight-card span {
  margin: 0;
}

.insight-card strong {
  font-size: 1.2rem;
  line-height: 1.2;
}

.stack-list,
.result-list,
.table-like {
  display: grid;
  gap: 12px;
}

.bar-row,
.mini-row {
  display: grid;
  gap: 8px;
}

.bar-meta,
.mini-meta,
.result-card,
.table-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-track,
.mini-track {
  height: 12px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill,
.mini-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #de9468);
}

.bar-fill.accent {
  background: linear-gradient(90deg, var(--success), #6ea78c);
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin: 16px 0 18px;
  align-items: stretch;
}

.filter-form label {
  display: grid;
  gap: 6px;
}

.filter-form span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.filter-form input,
.filter-form select,
.filter-form button {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.92);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.data-table thead th {
  border-top: none;
  background: rgba(231, 222, 202, 0.5);
}

.data-table tbody tr:hover {
  background: rgba(240, 195, 167, 0.12);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus-visible {
  outline: 2px solid rgba(191, 91, 61, 0.35);
  outline-offset: -2px;
}

.sort-header {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

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

.table-empty {
  padding: 22px 16px;
}

.table-entity-cell {
  min-width: 320px;
}

.table-entity-button {
  width: 100%;
  padding: 0;
  text-align: left;
  color: inherit;
}

.table-meta {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.badge.success {
  color: var(--success);
  border-color: rgba(40, 91, 71, 0.24);
  background: rgba(40, 91, 71, 0.08);
}

.badge.muted {
  color: var(--ink-soft);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.progress-pill-bar {
  width: 96px;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.progress-pill-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #de9468);
}

.detail-copy {
  line-height: 1.55;
  color: var(--ink-soft);
}

.detail-list {
  display: grid;
  gap: 10px;
}

.detail-list-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.detail-list-row:first-child {
  border-top: none;
}

.detail-list-row span,
.detail-list-row a {
  overflow-wrap: anywhere;
}

.question-answer-card {
  display: grid;
  gap: 12px;
}

.question-link {
  display: grid;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.question-link:hover strong {
  text-decoration: underline;
}

.compliance-checks {
  display: grid;
  gap: 10px;
}

.compliance-check {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(231, 222, 202, 0.4);
}

.entity-picker-shell {
  position: relative;
}

.entity-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.entity-picker-input {
  width: 100%;
  color: var(--ink);
}

.entity-picker-input:focus {
  outline: 2px solid rgba(191, 91, 61, 0.28);
  outline-offset: 1px;
}

.filter-form .entity-picker-clear {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  justify-self: auto;
}

.entity-picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 8px;
  max-height: 320px;
  padding: 10px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.98);
  box-shadow: var(--shadow);
}

.entity-picker-menu[hidden] {
  display: none;
}

.entity-picker-menu.entity-picker-menu-debug[hidden] {
  display: grid;
}

.entity-picker-option {
  width: 100%;
  padding: 2px 12px;
  text-align: left;
  /* border: 1px solid var(--line); */
  /* border-radius: 14px; */
  background: var(--surface-strong) !important;
  color: var(--ink);
  cursor: pointer;
}

.entity-picker-option:hover {
  background: #f8f1e6;
}

.entity-picker-option.active {
  border-color: rgba(191, 91, 61, 0.55);
  background: #f4e6d5;
  color: var(--ink);
}

.entity-picker-option.selected {
  border-color: rgba(40, 91, 71, 0.4);
  background: #edf4ef;
  color: var(--ink);
}

.entity-picker-option.selected.active {
  border-color: rgba(40, 91, 71, 0.55);
  background: #e4efe7;
}

.entity-picker-name,
.entity-picker-meta {
  color: var(--ink);
}

.entity-picker-meta {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.filter-form button {
  background: var(--ink);
  color: white;
  border: none;
  cursor: pointer;
  justify-self: start;
}

.filter-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.72);
}

.grow {
  grid-column: auto;
}

.filter-control-wide {
  grid-column: 1 / -1;
}

.filter-controls label,
.filter-form label,
.filter-form select,
.filter-form input {
  min-width: 0;
}

.inline-hint,
.search-feedback,
.pagination-summary {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.inline-hint {
  margin: 0 0 4px;
}

.search-feedback {
  min-height: 1.4rem;
  margin: -4px 0 12px;
}

.search-feedback.loading::before {
  content: "";
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  margin-right: 8px;
  border-radius: 50%;
  border: 2px solid var(--surface-muted);
  border-top-color: var(--accent);
  vertical-align: -0.08em;
  animation: spin 0.8s linear infinite;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pagination-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pagination button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  cursor: pointer;
}

.back-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: default;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-card {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.92);
  cursor: pointer;
}

.result-card strong,
.bar-meta strong,
.mini-meta strong,
.table-row strong {
  display: block;
}

.entity-summary,
.entity-summary-list {
  display: grid;
  gap: 4px;
}

.entity-summary-name,
.entity-summary-meta,
.entity-summary-extra {
  display: block;
  overflow-wrap: anywhere;
}

.entity-summary-meta,
.entity-summary-extra {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.entity-summary.compact .entity-summary-name {
  font-size: 0.95rem;
}

.bar-meta strong,
.mini-meta strong,
.result-card strong,
.table-row strong,
.result-card p,
.mini-meta span,
.bar-meta span {
  overflow-wrap: anywhere;
}

.result-meta {
  display: grid;
  gap: 4px;
  text-align: right;
  flex: 0 0 140px;
}

.result-card > div:first-child {
  min-width: 0;
}

.result-card p {
  margin: 4px 0 0;
}

.detail-empty,
.empty-state,
.empty-inline {
  color: var(--ink-soft);
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.92);
  color: var(--ink-soft);
}

.spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--surface-muted);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.detail-route-panel {
  min-height: 480px;
}

.detail-pane {
  display: grid;
  gap: 16px;
}

.detail-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.detail-kpis div {
  min-width: 180px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(231, 222, 202, 0.62);
}

.detail-kpis span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.detail-kpis strong {
  font-size: 1.1rem;
}

.card.inset {
  padding: 16px;
  box-shadow: none;
  background: rgba(255, 250, 240, 0.88);
}

@media (max-width: 980px) {
  .stats-grid,
  .stats-grid.compact,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .hero,
  .panel-header,
  .card-header,
  .detail-header,
  .bar-meta,
  .mini-meta,
  .result-card,
  .table-row {
    flex-direction: column;
  }

  .result-meta {
    flex-basis: auto;
    text-align: left;
  }

  .filter-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1400px);
    padding-top: 20px;
  }

  .hero-card {
    min-width: 0;
  }

  .filter-form,
  .view-nav {
    grid-template-columns: 1fr;
  }

  .filter-form button,
  .nav-link {
    width: 100%;
  }
}

.table-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.table-row:first-child {
  border-top: none;
}

@media (max-width: 1100px) {
  .stats-grid,
  .grid-two,
  .filter-form {
    grid-template-columns: 1fr;
  }

  .grow {
    grid-column: auto;
  }

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