/* ==========================================================================
   Long Equity: S&P 500 Linearity
   Simple 2-column layout (Chart Left | Table Right) matching raw-financials.css
   and comprehensive-valuation.css styling.
   ========================================================================== */

.ln-subtitle {
  margin: 8px 0 0;
  max-width: 780px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text2);
}

.ln-sync-notice {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #92400E;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
}

/* Main 2-Column Layout: Chart (Left) | Table (Right) */
.ln-main-grid {
  display: grid;
  grid-template-columns: minmax(430px, 0.95fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: stretch;
}

/* Left Chart Card */
.ln-chart-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.ln-chart-company-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.ln-chart-company-head .rf-company-id {
  flex: 1 1 auto;
  min-width: 0;
}

.ln-chart-company-head .rf-company-meta {
  min-width: 0;
}

.ln-chart-company-head .rf-company-title-row {
  flex-wrap: nowrap;
  min-width: 0;
}

.ln-chart-company-head .rf-company-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15.5px;
}

.ln-chart-company-head .rf-ticker-pill {
  flex-shrink: 0;
}

.ln-chart-company-head .rf-company-sector {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ln-company-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.ln-company-links .rf-link-btn {
  padding: 5px 9px;
  font-size: 11.5px;
  white-space: nowrap;
}

.ln-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ln-chart-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.ln-overlay-toggle {
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text2);
  border-radius: 9999px;
  padding: 5px 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.ln-overlay-toggle:hover {
  border-color: #1C1917;
  color: var(--text);
}

.ln-overlay-toggle.is-active {
  background: #1C1917;
  border-color: #1C1917;
  color: #FFFFFF;
}

.ln-overlay-toggle[hidden] {
  display: none !important;
}

.ln-chart-caption {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.pill-tray {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 9999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.tray-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 9999px;
  font-family: 'Manrope', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.tray-btn.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.08);
}

.ln-chart-canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 360px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 12px 8px;
}

.ln-chart-footnote {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text3);
}

/* Right Table Card */
.ln-table-panel {
  background: #FFFFFF;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.ln-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.ln-table-title-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.ln-table-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.ln-table-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  white-space: nowrap;
}

.ln-table-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

.ln-table-controls .pill-tray {
  flex-shrink: 0;
}

.ln-table-controls .tray-btn {
  padding: 4px 7.5px;
  font-size: 11px;
}

.ln-table-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 180px;
  min-width: 140px;
}

.ln-table-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text3);
  pointer-events: none;
}

.ln-table-search {
  width: 100%;
  height: 32px;
  padding: 4px 10px 4px 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  outline: none;
}

.ln-table-search:focus {
  border-color: #1C1917;
}

.ln-table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  max-height: 580px;
  overflow-y: auto;
}

.ln-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.ln-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
}

.ln-table thead th.col-rank {
  width: 38px;
  text-align: center;
}

.ln-table thead th.ln-sortable-th {
  padding: 0;
}

.ln-sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  width: 100%;
  padding: 10px 10px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.ln-sort-btn.is-num {
  justify-content: flex-end;
}

.ln-sort-btn:hover {
  color: var(--text);
  background: rgba(28, 25, 23, 0.03);
}

.ln-sortable-th.is-sorted .ln-sort-btn,
.ln-sortable-th.is-sorted .ln-sort-ind {
  color: #1B7C69;
  opacity: 1;
}

.ln-sortable-th.has-col-filter .ln-sort-btn {
  background: rgba(52, 181, 157, 0.08);
  color: #1B7C69;
}

.ln-sort-dot-wrap {
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #34B59D;
  flex-shrink: 0;
}

.ln-sortable-th.has-col-filter .ln-sort-dot-wrap {
  display: inline-block;
}

.ln-clear-filters-btn {
  flex-shrink: 0;
  border: 1px solid #FECDD3;
  background: #FFF1F2;
  color: #9F1239;
  border-radius: 9999px;
  padding: 2px 9px;
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}

.ln-clear-filters-btn[hidden] {
  display: none !important;
}

.ln-clear-filters-btn:hover {
  background: #FFE4E6;
}

/* Right-click column filter popover */
.ln-col-filter-popover {
  position: fixed;
  z-index: 1200;
  width: 248px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(28, 25, 23, 0.14), 0 2px 8px rgba(28, 25, 23, 0.06);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ln-col-filter-popover[hidden] {
  display: none !important;
}

.ln-cf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ln-cf-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

.ln-cf-close {
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 6px;
}

.ln-cf-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.ln-cf-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ln-cf-preset {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: 9999px;
  padding: 3px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.ln-cf-preset:hover {
  border-color: #34B59D;
  color: #1B7C69;
  background: #F0FDF9;
}

.ln-cf-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ln-cf-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ln-cf-field span {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
}

.ln-cf-input,
.ln-cf-select {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  outline: none;
}

.ln-cf-select {
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
}

.ln-cf-input:focus,
.ln-cf-select:focus {
  border-color: #1B7C69;
}

.ln-cf-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
}

.ln-cf-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 2px;
  border-top: 1px solid var(--border-subtle);
}

.ln-cf-btn-clear {
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text2);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: 'Manrope', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.ln-cf-btn-clear:hover {
  background: var(--surface2);
}

.ln-cf-btn-apply {
  border: none;
  background: #34B59D;
  color: #FFFFFF;
  border-radius: 8px;
  padding: 5px 12px;
  font-family: 'Manrope', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.ln-cf-btn-apply:hover {
  background: #2CA48D;
}

.ln-sort-ind {
  font-size: 10.5px;
  opacity: 0.45;
}

.ln-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s ease;
}

.ln-table tbody tr:hover {
  background: #F5FBF9;
}

.ln-table tbody tr.is-selected-row {
  background: #ECFDF5;
}

.ln-table tbody tr.is-selected-row td:first-child {
  box-shadow: inset 3px 0 0 #34B59D;
}

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

.ln-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.ln-table td.col-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text3);
  text-align: center;
}

.ln-table td.num-col,
.ln-table th.num-col {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.ln-company-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 175px;
}

.ln-row-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.ln-row-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ln-logo-fb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--text2);
}

.ln-company-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.ln-ticker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.ln-idx-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text3);
  flex-shrink: 0;
  line-height: 1.3;
}

.ln-idx-tag.is-sp400 {
  background: #F0FDF9;
  border-color: rgba(52, 181, 157, 0.35);
  color: #1B7C69;
}

.ln-company-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.ln-score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 9999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.ln-score-pill.is-elite {
  background: #ECFDF5;
  color: #065F46;
  border-color: #A7F3D0;
}

.ln-score-pill.is-strong {
  background: #E6F7F3;
  color: #1B7C69;
  border-color: rgba(52, 181, 157, 0.3);
}

.ln-score-pill.is-mid {
  background: #F1F5F9;
  color: #334155;
  border-color: #CBD5E1;
}

.ln-score-pill.is-low {
  background: #FFF1F2;
  color: #9F1239;
  border-color: #FECDD3;
}

.ln-val-pos {
  color: #047857;
  font-weight: 700;
}

.ln-val-neg {
  color: #BE123C;
  font-weight: 700;
}

.ln-empty-cell {
  padding: 36px 20px !important;
  text-align: center;
  color: var(--text3);
}

.ln-methodology-note {
  margin: 0 4px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text3);
}

@media (max-width: 1080px) {
  .ln-main-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ln-chart-panel,
  .ln-table-panel {
    height: auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .ln-chart-canvas-wrap {
    flex: none;
    height: 360px;
  }
  .ln-table-scroll {
    max-height: 540px;
  }
}

@media (max-width: 680px) {
  .ln-subtitle {
    font-size: 12.5px;
  }
  .ln-chart-company-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .ln-chart-company-head .rf-company-title-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .ln-chart-company-head .rf-company-name {
    white-space: normal;
    font-size: 14.5px;
    line-height: 1.25;
  }
  .ln-chart-company-head .rf-company-sector {
    white-space: normal;
    line-height: 1.3;
  }
  .ln-company-links {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .ln-chart-canvas-wrap {
    height: 270px;
    padding: 10px 8px 6px;
  }
  .ln-chart-toolbar,
  .ln-chart-toolbar-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }
  .ln-table-header {
    padding: 12px;
    flex-wrap: wrap;
  }
  .ln-table-controls {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
  .ln-table-controls .pill-tray {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ln-table-search-wrap {
    flex: 1 1 100%;
    width: 100%;
  }
  #ln-table-search {
    font-size: 16px;
  }
  .ln-table thead th,
  .ln-table td {
    padding: 8px 7px;
    font-size: 12px;
  }
  .ln-sort-btn {
    padding: 8px 7px;
  }
  .ln-table thead th.col-rank,
  .ln-table td.col-rank {
    width: 30px;
    padding-left: 8px;
    padding-right: 4px;
  }
  .ln-company-cell {
    min-width: 140px;
    gap: 6px;
  }
  .ln-company-name {
    max-width: 96px;
  }
}
