/* OD Model – Design refresh */
:root {
  --color-primary: #9F2E37;
  --color-primary-dark: #82252c;
  --color-primary-light: rgba(159, 46, 55, 0.08);
  --color-accent: #C59242;
  --color-accent-light: rgba(197, 146, 66, 0.12);
  --color-bg: #F7F4EC;
  --color-bg-subtle: #f0ede4;
  --color-surface: #DCDBD3;
  --color-surface-light: #e8e7e2;
  --color-text: #1a1a1a;
  --color-text-muted: #5c5c5c;
  --color-white: #fff;
  --font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --sidebar-width: 260px;
  --max-content: 1000px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* App layout: sidebar + main */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-primary);
  color: var(--color-white);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.logo {
  height: 42px;
  width: auto;
  display: block;
  object-fit: contain;
}

.main-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-white);
}

.nav-link.active {
  background: var(--color-white);
  color: var(--color-primary);
}

.nav-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem 3rem;
  max-width: calc(100vw - var(--sidebar-width));
}

/* Sections */
.page-section {
  display: none;
  animation: sectionIn 0.25s ease;
}

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

@keyframes sectionIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-section h1 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.section-intro {
  color: var(--color-text-muted);
  margin: 0 0 1.75rem;
  max-width: 56ch;
  font-size: 0.95rem;
}

/* Cards */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-surface-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
  border-left: 3px solid var(--color-primary);
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--color-surface);
}

.scoring-card .data-table {
  max-width: 420px;
}

/* Data tables (non-metrics) */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-surface-light);
}

.data-table thead th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--color-primary-light);
}

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

/* Metrics table */
.metrics-card {
  overflow: hidden;
  padding: 0;
}

.metrics-table-wrap {
  overflow-x: auto;
  margin-bottom: 0;
  -webkit-overflow-scrolling: touch;
}

.metrics-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.metrics-table th,
.metrics-table td {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-surface-light);
  vertical-align: top;
}

.metrics-table thead th {
  background: var(--color-surface-light);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}

.metrics-table .metrics-block-header {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: var(--color-white);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.65rem 0.5rem;
  letter-spacing: 0.02em;
}

.metrics-table .metrics-pct {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.metrics-table .metrics-subhead th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metrics-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.5);
}

.metrics-table tbody tr:hover {
  background: var(--color-primary-light);
}

.metrics-date-range {
  margin: 0;
  padding: 1rem 1.75rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-surface-light);
}

/* OPI Scoring */
.opi-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 1rem;
}

.opi-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.opi-metrics-block {
  background: var(--color-bg-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--color-surface-light);
}

.opi-block-head {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 0.65rem;
}

.opi-metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.opi-metrics-table th,
.opi-metrics-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-surface-light);
}

.opi-metrics-table thead th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.opi-entity-tables {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.opi-entity-wrap {
  min-width: 0;
}

.opi-entity-wrap .opi-block-head {
  margin-bottom: 0.5rem;
}

.opi-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.opi-entity-table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.opi-entity-table th,
.opi-entity-table td {
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--color-surface-light);
  white-space: nowrap;
}

.opi-entity-table thead th {
  background: var(--color-surface-light);
  font-weight: 600;
  color: var(--color-text);
}

.opi-entity-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.4);
}

.opi-entity-table tbody tr:hover {
  background: var(--color-primary-light);
}

.opi-growth-table {
  min-width: 720px;
}

.opi-index-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.opi-index-table th,
.opi-index-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-surface-light);
}

.opi-index-table thead th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.opi-index-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.4);
}

.opi-ranking-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-surface-light);
}

.opi-ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.opi-ranking-table th,
.opi-ranking-table td {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-surface-light);
}

.opi-ranking-table thead th {
  background: var(--color-surface-light);
  font-weight: 600;
  color: var(--color-text);
}

.opi-ranking-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.4);
}

@media (max-width: 1024px) {
  .opi-metrics-grid {
    grid-template-columns: 1fr;
  }

  .opi-entity-tables {
    grid-template-columns: 1fr;
  }
}

/* Finance */
.finance-ohi-weight {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--color-text-muted);
}

.finance-ohi-weight strong {
  color: var(--color-primary);
}

.finance-metrics-table {
  max-width: 420px;
}

.finance-summary-table,
.finance-ranking-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.finance-summary-table th,
.finance-summary-table td,
.finance-ranking-table th,
.finance-ranking-table td {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-surface-light);
}

.finance-th-group {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.7rem;
  text-align: center;
}

.finance-summary-table thead tr:last-child th,
.finance-ranking-table thead tr:last-child th {
  background: var(--color-surface-light);
  color: var(--color-text);
  font-weight: 600;
}

.finance-summary-table tbody tr:nth-child(even),
.finance-ranking-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.4);
}

.finance-summary-table tbody tr:hover,
.finance-ranking-table tbody tr:hover {
  background: var(--color-primary-light);
}

/* ODM Scoring table */
.odm-scoring-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.odm-scoring-table th,
.odm-scoring-table td {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-surface-light);
}

.odm-scoring-table thead tr:first-child th.finance-th-group {
  text-align: center;
}

.odm-scoring-table thead tr:last-child th {
  background: var(--color-surface-light);
  color: var(--color-text);
  font-weight: 600;
}

.odm-scoring-table tbody tr:nth-child(even) {
  background: rgba(247, 244, 236, 0.4);
}

.odm-scoring-table tbody tr:hover {
  background: var(--color-primary-light);
}

/* Summary chart containers */
.chart-container {
  margin-bottom: 1.5rem;
}

.chart-container:last-child {
  margin-bottom: 0;
}

.summary-chart-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 1.25rem;
}

.summary-bubble-chart {
  min-height: 440px;
  width: 100%;
  padding: 0.25rem 0;
}

.summary-bubble-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.summary-bubble-svg {
  shape-rendering: geometricPrecision;
}

#summary .chart-container {
  padding: 1.5rem 1.75rem;
}

.summary-chart {
  min-height: 280px;
  width: 100%;
}

.summary-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    width: 220px;
    min-width: 220px;
  }

  .main-content {
    padding: 1.5rem 1.25rem;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding: 0;
  }

  .sidebar-brand {
    padding: 0.75rem 1rem;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
  }

  .logo {
    height: 36px;
  }

  .main-nav {
    flex: 1;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
  }

  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
    max-width: 100%;
  }

  .page-section h1 {
    font-size: 1.5rem;
  }
}

/* LC Dashboard */
.lc-dashboard {
  max-width: var(--max-content);
  margin: 0 auto;
}

.lc-dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-surface);
}

.lc-dashboard-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1 1 100%;
}

@media (min-width: 640px) {
  .lc-dashboard-title {
    flex: 1 1 auto;
  }
}

.lc-dashboard-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lc-dashboard-label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.lc-dashboard-select {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  border: 1px solid var(--color-surface);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-text);
  min-width: 160px;
}

.lc-section {
  margin-bottom: 2.5rem;
}

.lc-section-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.lc-odi-blocks,
.lc-ohi-metrics,
.lc-opi-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.lc-metric-block {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-surface);
}

.lc-metric-name {
  font-weight: 500;
  color: var(--color-text-muted);
}

.lc-metric-value {
  font-weight: 600;
  color: var(--color-text);
}

.lc-metric-odi .lc-metric-value { color: var(--color-primary); }
.lc-metric-opi .lc-metric-value { color: var(--color-accent); }
.lc-metric-ohi .lc-metric-value { color: #2e7d32; }

.lc-index-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.lc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.lc-table th,
.lc-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--color-surface);
}

.lc-table thead th {
  background: var(--color-surface-light);
  font-weight: 600;
  color: var(--color-text);
}

.lc-table tbody tr:nth-child(even) {
  background: var(--color-bg-subtle);
}

.lc-benchmarks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 640px) {
  .lc-benchmarks {
    grid-template-columns: 1fr;
  }
}

.lc-benchmark-card {
  background: var(--color-white);
  border: 1px solid var(--color-surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.lc-benchmark-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.lc-benchmark-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.lc-chart-wrap {
  min-height: 100px;
  width: 100%;
}

.lc-chart-wrap.lc-line-chart {
  min-height: 120px;
}

.lc-detail-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.lc-detail-card .opi-card-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.lc-detail-card p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}
