/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Dark theme (default) === */
:root {
  --bg:           #141414;
  --surface:      #1c1c1e;
  --surface-2:    #2c2c2e;
  --border:       #3a3a3c;
  --border-faint: #2c2c2e;
  --text:         #f5f5f7;
  --text-2:       #aeaeb2;
  --text-3:       #636366;
  --accent:       #0a84ff;
  --green:        #30d158;
  --green-dim:    rgba(48, 209, 88, 0.12);
  --blue-dim:     rgba(10, 132, 255, 0.12);
  --blue-solid:   #1a2839; /* pre-blended blue-dim over --surface, for sticky cells */
  --red:          #ff453a;
  --red-dim:      rgba(255, 69, 58, 0.12);
  --amber:        #ffd60a;
  --amber-dim:    rgba(255, 214, 10, 0.1);
  --nav-bg:       rgba(20, 20, 20, 0.82);
  --shadow:       0 1px 0 var(--border-faint);
  --radius:       6px;
  --radius-lg:    10px;
  --t:            0.18s ease;
  --slider-blue:  #5ac8fa;
}

/* === Light theme === */
[data-theme="light"] {
  --bg:           #f2f2f7;
  --surface:      #ffffff;
  --surface-2:    #f2f2f7;
  --border:       #d1d1d6;
  --border-faint: #e5e5ea;
  --text:         #1d1d1f;
  --text-2:       #6e6e73;
  --text-3:       #aeaeb2;
  --accent:       #0071e3;
  --green:        #1c7c3a;
  --green-dim:    rgba(28, 124, 58, 0.08);
  --blue-dim:     rgba(0, 113, 227, 0.08);
  --blue-solid:   #ebf4fd; /* pre-blended blue-dim over --surface, for sticky cells */
  --red:          #c0392b;
  --red-dim:      rgba(192, 57, 43, 0.08);
  --amber:        #b8860b;
  --amber-dim:    rgba(184, 134, 11, 0.08);
  --nav-bg:       rgba(242, 242, 247, 0.88);
  --shadow:       0 1px 0 var(--border);
  --slider-blue:  #0a84ff;
}

/* === Base === */
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === Top Nav === */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-faint);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.75rem;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0.1rem;
  list-style: none;
  flex: 1;
}

.nav-links a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color var(--t), background var(--t);
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: var(--accent); }
.nav-links a.nav-co { color: var(--accent); }
.nav-links a.dim { opacity: 0.4; pointer-events: none; }

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.95rem;
  transition: color var(--t), border-color var(--t);
  flex-shrink: 0;
}
.theme-btn:hover { color: var(--text); border-color: var(--text-3); }

/* === Font-size controls (injected by site.js) === */
.font-ctrl {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  margin-right: 0.55rem;
  flex-shrink: 0;
}
.font-ctrl-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 0.1rem;
  letter-spacing: 0.01em;
  user-select: none;
}
.font-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color var(--t), border-color var(--t), background var(--t);
  flex-shrink: 0;
  padding: 0;
}
.font-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text-3); background: var(--surface-2); }
.font-btn:disabled { opacity: 0.28; cursor: default; }

/* === Sub-nav (company sub-pages) === */
.sub-nav {
  position: sticky;
  top: 48px;
  z-index: 49;
  background: var(--surface);
  border-bottom: 1px solid var(--border-faint);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sub-nav::-webkit-scrollbar { display: none; }

.sub-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.75rem;
  display: flex;
  gap: 0;
}

.sub-nav a {
  display: block;
  padding: 0.55rem 0.9rem;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t);
  white-space: nowrap;
}
.sub-nav a:hover { color: var(--text); }
.sub-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* === Page === */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.75rem 4rem;
}

/* === Header === */
.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-header .meta {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-top: 0.2rem;
}

/* === Landing hero === */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0 3rem;
  text-align: center;
}

.landing-svg {
  width: 480px;
  max-width: 100%;
  height: auto;
  margin-bottom: 2.5rem;
}

.landing h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.landing .tagline {
  font-size: 0.95rem;
  color: var(--text-2);
  max-width: 500px;
  line-height: 1.6;
  margin-bottom: 3rem;
}

/* === Company grid (landing) === */
.co-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border-faint);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 780px;
  width: 100%;
}

.co-card {
  background: var(--surface);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: background var(--t);
  display: block;
}
.co-card:hover { background: var(--surface-2); }
.co-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.3rem; }
.co-card .desc { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; }
.co-card .cs {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-top: 0.65rem;
}
.co-card.dim { opacity: 0.4; pointer-events: none; }

/* === BRK hub layout === */
.hub-intro {
  max-width: 680px;
  margin-bottom: 2.5rem;
}
.hub-intro p {
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.7;
  margin-top: 0.5rem;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-faint);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hub-card {
  background: var(--surface);
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: background var(--t);
  display: block;
}
.hub-card:hover { background: var(--surface-2); }
.hub-card h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--accent);
}
.hub-card .desc { font-size: 0.78rem; color: var(--text-2); line-height: 1.5; }
.hub-card.dim { opacity: 0.4; pointer-events: none; }
.hub-card.dim h3 { color: var(--text-3); }

.hub-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 1.6rem 0 0.5rem;
}

/* === Stats strip === */
.stats-strip {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.stat {
  flex: 1;
  padding: 0.67rem 0.85rem;
  border-right: 1px solid var(--border-faint);
  min-width: 0;
}
.stat:last-child { border-right: none; }

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat-value.pos { color: var(--green); }
.stat-value.neg { color: var(--red); }

/* === Chart === */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 1rem;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 260px;
}

/* === Table container === */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--border-faint);
}

.table-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.table-hint {
  font-size: 0.75rem;
  color: var(--text-2);
}

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

/* === Data table === */
table.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

table.dt thead th {
  padding: 0.37rem 0.5rem;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-faint);
  white-space: normal;
  line-height: 1.3;
  background: var(--surface);
}
table.dt thead th:first-child {
  text-align: left;
  padding-left: 0.85rem;
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--surface);
}
table.dt thead th:last-child { padding-right: 0.85rem; }

/* Column header tooltips */
th[data-tip] {
  position: relative;
  cursor: help;
}
th[data-tip] span {
  border-bottom: 1px dotted var(--border);
  padding-bottom: 1px;
}
th[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  width: 200px;
  white-space: normal;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
th[data-tip]:first-child::after { right: auto; left: 0; }
th[data-tip]:hover::after { opacity: 1; }

/* Data rows */
table.dt tbody tr.dr {
  cursor: pointer;
  transition: background var(--t);
}
table.dt tbody tr.dr:hover { background: var(--surface-2); }
table.dt tbody tr.dr.open  { background: var(--surface-2); }
/* Keep sticky first-child in sync with row hover/open */
table.dt tbody tr.dr:hover td:first-child { background: var(--surface-2); }
table.dt tbody tr.dr.open  td:first-child { background: var(--surface-2); }

table.dt tbody td {
  padding: 0.33rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--border-faint);
  white-space: nowrap;
  color: var(--text);
}
table.dt tbody td:first-child {
  text-align: left;
  padding-left: 0.85rem;
  font-weight: 500;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}
table.dt tbody td:last-child { padding-right: 0.85rem; text-align: right; }

/* Value coloring */
td.neg { color: var(--red); }
td.hl-g { background: var(--green-dim); color: var(--green); font-weight: 600; }
td.hl-r { background: var(--red-dim); color: var(--red); font-weight: 600; }
td.hl-a { background: var(--amber-dim); color: var(--amber); font-weight: 600; }

td.acq-cell {
  font-size: 0.78rem;
  color: var(--text-2);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.acq-cell strong { color: var(--text); font-weight: 600; }

/* % of CFOA row */
tr.pct-row { cursor: default; }
tr.pct-row td {
  padding: 0.22rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-faint);
  font-style: italic;
}
tr.pct-row td:first-child { padding-left: 0.85rem; font-weight: 500; color: var(--text-2); }
tr.pct-row td:last-child { padding-right: 0.85rem; }

/* Expand arrow */
.arr {
  display: inline-block;
  width: 14px;
  height: 14px;
  font-size: 0.6rem;
  text-align: center;
  line-height: 14px;
  color: var(--text-3);
  margin-right: 0.4rem;
  transition: transform var(--t), color var(--t);
  vertical-align: middle;
}
tr.dr.open .arr { transform: rotate(90deg); color: var(--accent); }

/* === Detail panel === */
tr.detail-tr { cursor: default; }
tr.detail-tr td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border-faint);
}

.detail-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
tr.detail-tr.open .detail-panel { max-height: 600px; }

.detail-body {
  padding: 1.25rem 1.5rem 1.25rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
  border-top: 1px solid var(--border-faint);
}

.detail-col h5 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: 0.65rem;
}

.detail-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.detail-col li {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.45;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}
.detail-col li.li-acq { border-left-color: var(--amber); }
.detail-col li.li-eq  { border-left-color: var(--accent); }

.kv { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px solid var(--border-faint); font-size: 0.8rem; }
.kv:last-child { border-bottom: none; }
.kv .v { font-weight: 600; }
.detail-ctx { font-size: 0.8rem; color: var(--text-2); line-height: 1.6; margin-bottom: 0.75rem; }

/* === Footer row — blue-dim highlight across all tables === */
table.dt tfoot td {
  padding: 0.4rem 0.5rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.82rem;
  border-top: 1px solid var(--accent);
  color: var(--text);
  white-space: nowrap;
  background: var(--blue-dim);
}
table.dt tfoot td:first-child {
  text-align: left;
  padding-left: 0.85rem;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--blue-solid);
}
table.dt tfoot td:last-child { padding-right: 0.85rem; }

tr.pct-total td {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
  padding: 0.22rem 0.5rem;
  font-style: italic;
  border-top: none;
  border-bottom: none;
}
tr.pct-total td:first-child { padding-left: 0.85rem; }
tr.pct-total td:last-child { padding-right: 0.85rem; }

/* === Article layout (About / Blog) === */
.article-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 5rem;
}

.article-page h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.article-page .article-meta {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-bottom: 2rem;
}

.article-page h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.article-page p {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 1rem;
}

.article-page ul {
  margin: 0 0 1rem 1.5rem;
}
.article-page ul li {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.75;
}

.blog-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 1.5rem;
}

.blog-item {
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-faint);
  text-decoration: none;
  color: var(--text);
  transition: background var(--t);
  display: block;
}
.blog-item:last-child { border-bottom: none; }
.blog-item:hover { background: var(--surface-2); }
.blog-item h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.2rem; }
.blog-item .bdate { font-size: 0.75rem; color: var(--text-2); }
.blog-item .bexcerpt { font-size: 0.8rem; color: var(--text-2); margin-top: 0.3rem; line-height: 1.5; }

.blog-empty {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-2);
  font-size: 0.85rem;
  margin-top: 1.5rem;
}

/* === Stub page (coming soon) === */
.stub-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  padding: 3rem 1.75rem;
}
.stub-wrap h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.stub-wrap p { font-size: 0.85rem; color: var(--text-2); max-width: 360px; line-height: 1.6; }
.stub-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 1rem;
}

/* === Hero banner (company pages) === */
.co-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.75rem;
  height: 280px;
  background: var(--surface-2);
  display: flex;
  align-items: flex-end;
}

.co-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.co-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0.72) 0%,
    rgba(0,0,0,0.45) 45%,
    rgba(0,0,0,0.05) 100%
  );
}

.co-hero-content {
  position: relative;
  z-index: 1;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.co-hero-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  object-position: left center;
}

.co-hero-facts {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
}

.co-hero-fact {
  color: rgba(255,255,255,0.82);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.co-hero-fact strong {
  color: #fff;
  font-weight: 700;
  margin-right: 0.3rem;
}

/* === Network / route map section === */
.map-section {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 1.75rem;
}

.map-section img {
  width: 100%;
  height: auto;
  display: block;
}

/* === BNSF / company page additions === */

/* Inline acquisition tag (e.g. "acq. Feb 2010") */
.acq-tag {
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(10,132,255,0.1);
  border: 1px solid rgba(10,132,255,0.2);
  border-radius: 3px;
  padding: 0.06rem 0.38rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  letter-spacing: 0;
}

/* 2010 acquisition row — light blue tint */
tr.acq-row td { background: rgba(10,132,255,0.05) !important; }
tr.acq-row td:first-child { background: linear-gradient(rgba(10,132,255,0.05), rgba(10,132,255,0.05)), var(--surface) !important; }

/* Chart footnote (below canvas) */
.chart-footnote {
  font-size: 0.7rem;
  color: var(--text-2);
  padding: 0.4rem 1.5rem 0.9rem;
  line-height: 1.5;
  margin: 0;
}

/* CEO / analyst pull-quote below a chart */
.chart-quote {
  margin: 0.5rem 1.5rem 1.1rem;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 6px 6px 0;
}
.chart-quote p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 0.9rem;
  font-style: italic;
}
.chart-quote p:last-of-type {
  margin-bottom: 0.5rem;
}
.chart-quote cite {
  font-size: 1rem;
  color: var(--text-2);
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Pre-acquisition label */
.pre-tag {
  color: var(--text-2);
  font-size: 0.7rem;
  margin-left: 0.35rem;
  font-weight: 400;
}

/* Acquisition separator banner inside tbody */
table.dt tbody td.acq-banner {
  text-align: center !important;
  font-size: 0.72rem;
  color: var(--amber);
  background: var(--amber-dim) !important;
  padding: 0.28rem 1.25rem !important;
}

/* Numeric last-column override (defeats :last-child left-align) */
table.dt tbody td.num-last,
table.dt tfoot td.num-last { text-align: right !important; }

/* === SOTP / Valuation page === */

/* Section header rows inside tbody */
tr.sotp-section td {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.28rem 0.85rem;
  text-align: left !important;
  border-bottom: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 5;
}
/* Sticky first-child backgrounds for special row types */
tr.sotp-section td:first-child   { background: var(--surface-2) !important; z-index: 5 !important; }
tr.sotp-subtotal td:first-child  { background: var(--blue-solid) !important; }
tr.pct-row td:first-child        { background: var(--surface-2) !important; }
tr.has-toggle:hover td:first-child { background: var(--surface-2) !important; }

/* Yield-detail columns — hidden by default, shown when table has .show-yield */
th.yield-col,
td.yield-col { display: none; }
table.dt.show-yield th.yield-col,
table.dt.show-yield td.yield-col {
  display: table-cell !important;
  text-align: right !important;
  padding-right: 1.25rem;
}

/* MSR sub-rows */
tr.sub-row { display: none; }
tr.sub-row.expanded { display: table-row; }
tr.sub-row td { color: var(--text-2); font-size: 0.82rem; }
tr.sub-row td:first-child {
  padding-left: 2.4rem;
  font-style: italic;
  font-weight: 400;
}

/* Toggleable parent row (Total MSR) — only label bold, values normal */
tr.has-toggle td:first-child { cursor: pointer; user-select: none; font-weight: 600; }
tr.has-toggle:hover td { background: var(--surface-2); }
.row-arrow {
  display: inline-block;
  font-size: 0.58rem;
  color: var(--accent);
  margin-right: 0.42rem;
  transition: transform 0.18s ease;
  vertical-align: middle;
  line-height: 1;
}
tr.has-toggle.open .row-arrow { transform: rotate(90deg); }

/* Haircut row (explanatory / dim) */
tr.haircut-row td {
  color: var(--text-3);
  font-style: italic;
  font-size: 0.81rem;
}

/* Cell-level hover tooltips (data-tip on TD) */
td[data-tip] {
  position: relative;
  cursor: help;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
td[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.5rem 0.72rem;
  border-radius: var(--radius);
  width: 220px;
  white-space: normal;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
td[data-tip]:hover::after { opacity: 1; }

/* SOTP section subtotal rows — blue-dim for consistency */
tr.sotp-subtotal td {
  background: var(--blue-dim);
  font-weight: 600;
  font-size: 0.83rem;
  color: var(--text-2);
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--border-faint);
}
tr.sotp-subtotal td:first-child {
  text-align: left !important;
  padding-left: 0.85rem;
  font-style: italic;
}

/* Unified blue tfoot — override for any residual table-specific colors */
#capitalTable tfoot td,
#sotpTable tfoot td {
  background: var(--blue-dim) !important;
  border-top: 1px solid var(--accent) !important;
  color: var(--text) !important;
}
/* Sticky first-child in tfoot must be opaque — no transparency */
#capitalTable tfoot td:first-child,
#sotpTable tfoot td:first-child {
  background: var(--blue-solid) !important;
}
#sotpTable tfoot td strong { color: var(--accent); }

/* Yield toggle button */
.sotp-yield-btn {
  font-size: 0.71rem;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(10, 132, 255, 0.35);
  border-radius: var(--radius);
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
  letter-spacing: 0;
  white-space: nowrap;
}
.sotp-yield-btn:hover { background: rgba(10,132,255,0.12); }
.sotp-yield-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Negative value spans inside table cells */
span.neg { color: var(--red); }

/* === MSR wide table === */
.msr-table-wrap {
  overflow: hidden;
  margin-bottom: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
}

table.msr {
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  min-width: 1200px;
  width: 100%;
  table-layout: fixed;
}

table.msr thead th {
  padding: 0.33rem 0.45rem;
  text-align: right;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: normal;
  line-height: 1.3;
  background: var(--surface);
}

table.msr thead th:first-child {
  text-align: left;
  padding-left: 0.85rem;
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  min-width: 160px;
}

table.msr tbody td {
  padding: 0.28rem 0.45rem;
  text-align: right;
  border-bottom: 1px solid var(--border-faint);
  white-space: nowrap;
  color: var(--text);
}

table.msr tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: left;
  padding-left: 0.85rem;
  z-index: 2;
  font-weight: 600;
}

/* Sticky first-col backgrounds */
tr.msr-section td:first-child   { background: var(--surface-2) !important; }
tr.msr-sub td:first-child        { background: var(--surface) !important; }
tr.msr-total-row td:first-child  { background: var(--surface) !important; }
tr.msr-persistent td:first-child { background: var(--surface) !important; }

/* Section header rows */
tr.msr-section td {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.45rem !important;
  border-bottom: 1px solid var(--border);
}

/* Sub-segment rows */
tr.msr-sub td {
  color: var(--text-2);
}
tr.msr-sub td:first-child {
  padding-left: 2.4rem !important;
  font-weight: 400;
  font-style: italic;
}

/* Net profit row — blue text, bold, accent separator */
tr.msr-np td {
  border-top: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
}
tr.msr-np td:first-child { background: var(--surface) !important; }

/* ROE row */
tr.msr-roe td { color: var(--accent); font-weight: 600; background: rgba(10,132,255,.10); }
tr.msr-roe td:first-child { background: linear-gradient(rgba(10,132,255,.10), rgba(10,132,255,.10)), var(--surface) !important; }

/* Negative cell */
td.msr-neg { color: var(--red) !important; }

/* Sign-flip cells */
td.msr-pos-turn { color: var(--green) !important; font-style: italic; font-size: 0.78rem; }
td.msr-neg-turn { color: var(--red)   !important; font-style: italic; font-size: 0.78rem; }

/* Null / em-dash cells */
td.msr-null { color: var(--text-3); }

/* Per-row expand arrow */
.msr-arr {
  display: inline-block;
  font-size: 0.55rem;
  color: var(--accent);
  margin-right: 0.45rem;
  transition: transform 0.18s ease;
  vertical-align: middle;
  line-height: 1;
}
tr.msr-total-row { cursor: pointer; }
tr.msr-total-row td { font-weight: 700 !important; }
tr.msr-total-row:hover td { background: var(--surface-2) !important; }
tr.msr-total-row:hover td:first-child { background: var(--surface-2) !important; }
tr.msr-total-row.open .msr-arr { transform: rotate(90deg); }

/* Persistent rows (Net Profit, Est. ROE) */
tr.msr-persistent td:first-child { font-weight: 600; }

/* Legacy expand-only (kept for any residual references) */
tr.msr-expand-only { display: none; }
table.msr.msr-expanded tr.msr-expand-only { display: table-row; }

/* Heatmap toggle button */
.hm-btn {
  font-size: 0.71rem;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  flex-shrink: 0;
}
.hm-btn:hover { background: var(--surface-2); }
.hm-btn.active {
  color: var(--green);
  border-color: rgba(52,199,89,0.50);
  background: rgba(52,199,89,0.12);
}

/* Toggle button */
.msr-toggle {
  font-size: 0.71rem;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(10, 132, 255, 0.35);
  border-radius: var(--radius);
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: background var(--t);
  white-space: nowrap;
}
.msr-toggle:hover { background: var(--blue-dim); }

/* === Chart label-toggle button === */
.chart-label-btn {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  padding: 0.2rem 0.65rem;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
  white-space: nowrap;
  flex-shrink: 0;
}
.chart-label-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
.chart-label-btn.active {
  color: var(--accent);
  border-color: rgba(10, 132, 255, 0.4);
  background: var(--blue-dim);
}

/* === noUiSlider chart range slider === */
.chart-slider-wrap {
  padding: 1.1rem 0.5rem 0.25rem;
}
.chart-slider { height: 4px; }

/* Base track */
.noUi-target {
  background: var(--surface-2) !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 4px !important;
  height: 4px !important;
}
/* Selected range fill */
.noUi-connect {
  background: var(--slider-blue) !important;
  opacity: 0.7;
}
/* Handles */
.noUi-handle {
  background: var(--slider-blue) !important;
  border: 2px solid var(--surface) !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.35) !important;
  border-radius: 50% !important;
  width: 16px !important;
  height: 16px !important;
  right: -8px !important;
  top: -7px !important;
  cursor: grab;
}
.noUi-handle:active { cursor: grabbing; }
.noUi-handle:focus  { outline: none !important; }
.noUi-handle::before,
.noUi-handle::after { display: none !important; }
/* Tooltips */
.noUi-tooltip {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  color: var(--text-2);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .detail-body { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .stats-strip { flex-wrap: wrap; }
  .stat { flex: 1 1 45%; border-right: none; border-bottom: 1px solid var(--border-faint); }
  .detail-body { grid-template-columns: 1fr; gap: 1.25rem; }
  .landing h1 { font-size: 1.6rem; }
}
@media (max-width: 640px) {
  .page { padding: 1.25rem 1rem 3rem; }
  .nav-inner { padding: 0 1rem; }
  .sub-nav-inner { padding: 0 1rem; }
  .article-page { padding: 1.5rem 1rem 4rem; }
}

@media (max-width: 768px) {
  .hub-grid { grid-template-columns: 1fr; }
}

/* === CAGR definition tooltip === */
.cagr-def {
  position: relative;
  cursor: help;
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px dotted var(--accent);
  vertical-align: middle;
}
.cagr-def::after {
  content: attr(data-tip);
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translateY(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  width: 310px;
  white-space: normal;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.cagr-def:hover::after { opacity: 1; }
