/* ==========================================================================
   Long Equity: Raw Financials (10K/10Q)
   Streamlined UI consistent with Portfolio Builder (warm stone) & Fund Overlap
   ========================================================================== */

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

:root {
  --bg: #FFFFFF;
  --surface: #FAF9F7;
  --surface2: #F2EFEB;
  --border: #E5E0D8;
  --border-subtle: #EAE6DF;
  --text: #1C1917;
  --text2: #57534E;
  --text3: #78716C;
  --accent: #0284C7;
  --green: #10B981;
  --green-dark: #047857;
  --green-bg: #ECFDF5;
  --radius: 16px;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.04);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Compact Hero Header */
.top-header {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.page-title {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 400;
  letter-spacing: -0.03em;
  color: #18181B;
  line-height: 1.14;
  margin: 0;
}

.page-title-bold {
  font-weight: 600;
  color: #171717;
}

/* Main Workspace */
.rf-workspace {
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.rf-controls-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rf-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.rf-search-col {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rf-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

#rf-search-input {
  flex: 1;
  width: 100%;
  height: 40px;
  padding: 8px 14px 8px 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#rf-search-input:focus {
  border-color: #1C1917;
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.08);
}

.rf-search-submit {
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: #1C1917;
  color: #ffffff;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.rf-search-submit:hover {
  background: #292524;
}

.rf-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 78px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(28, 25, 23, 0.12);
  max-height: 290px;
  overflow-y: auto;
  z-index: 40;
}

.rf-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
}

.rf-search-item:last-child {
  border-bottom: none;
}

.rf-search-item:hover {
  background: var(--surface);
}

.rf-search-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rf-search-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.rf-search-logo img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.rf-search-logo-fallback {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 800;
  color: #1C1917;
}

.rf-search-item-ticker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  flex-shrink: 0;
}

.rf-search-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rf-quick-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.rf-quick-label {
  font-size: 11.5px;
  color: var(--text3);
  font-weight: 600;
  margin-right: 2px;
}

.quick-chip {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-chip:hover {
  border-color: #1C1917;
  color: var(--text);
}

.quick-chip.active {
  background: #1C1917;
  border-color: #1C1917;
  color: #ffffff;
}

.rf-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

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

.tray-btn {
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'Manrope', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tray-btn:hover {
  color: var(--text);
}

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

.rf-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid #047857;
  background: #10B981;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.22);
  transition: background 0.15s ease;
  white-space: nowrap;
}

.rf-csv-btn:hover {
  background: #059669;
}

/* Company Strip */
.rf-company-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.rf-company-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.rf-logo-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.rf-logo-box img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  display: block;
}

.rf-logo-fallback {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  color: #1C1917;
}

.rf-company-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rf-company-sector {
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  margin-top: 3px;
}

.rf-company-sector[hidden] {
  display: none;
}

.rf-company-name {
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.rf-ticker-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #1C1917;
  color: #ffffff;
}

.rf-split-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text2);
}

.rf-split-pill.has-splits {
  background: var(--green-bg);
  border-color: #6EE7B7;
  color: var(--green-dark);
}

.rf-raw-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rf-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.rf-link-btn:hover {
  border-color: #1C1917;
  background: var(--surface2);
}

/* Panel Header & Table */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.rf-table-head-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
}

.panel-sub {
  font-size: 12px;
  color: var(--text2);
}

.rf-status-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
}

.rf-error-box {
  padding: 12px 14px;
  border-radius: 10px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.rf-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.rf-table th,
.rf-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.rf-table thead th {
  background: var(--surface);
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 700;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}

.rf-table thead th.sticky-col {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 230px;
}

.rf-table tbody td.sticky-col {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 4;
  background: #ffffff;
  border-right: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

.rf-table tbody tr:hover td {
  background: #F9F8F6;
}

.rf-table tbody tr.is-highlight td {
  background: #FAF8F4;
  font-weight: 700;
}

.rf-table tbody td.num-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.rf-table tbody td.is-neg {
  color: #DC2626;
}

.rf-table tbody td.is-empty {
  color: var(--text3);
}

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

.rf-metric-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rf-metric-cell.is-indented {
  padding-left: 10px;
}

.rf-split-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 9999px;
  background: var(--green-bg);
  color: var(--green-dark);
  border: 1px solid #A7F3D0;
}

.rf-period-link {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.rf-period-link:hover .rf-period-title {
  color: var(--accent);
  text-decoration: underline;
}

.rf-period-date {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
}

.rf-xbrl-row td {
  background: #FCFCFA;
}

.rf-xbrl-cell-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft, rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.25);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rf-xbrl-cell-link:hover {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--accent);
  text-decoration: none;
}

.rf-table tbody tr.is-optional td {
  background: #FAFDFB;
}

.rf-optional-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 9999px;
  background: #F4F4F5;
  color: #52525B;
  border: 1px solid #E4E4E7;
}

.rf-additional-panel {
  margin-top: 14px;
  padding: 12px 16px;
}

.rf-additional-panel.is-collapsed {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rf-additional-panel.is-collapsed:hover {
  border-color: rgba(16, 185, 129, 0.45);
}

.rf-additional-panel.is-collapsed:hover .rf-toggle-metrics-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.rf-metrics-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  cursor: pointer;
}

.rf-metrics-header:hover .rf-toggle-metrics-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.rf-additional-panel:not(.is-collapsed) .rf-metrics-header {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.rf-metrics-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  margin-left: 6px;
}

.rf-metrics-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rf-reset-metrics-btn,
.rf-toggle-metrics-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text2);
  border-radius: 9999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.rf-reset-metrics-btn:hover:not(:disabled),
.rf-toggle-metrics-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rf-reset-metrics-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.rf-toggle-metrics-btn svg {
  transition: transform 0.15s ease;
}

.rf-additional-panel:not(.is-collapsed) .rf-toggle-metrics-btn svg {
  transform: rotate(180deg);
}

.rf-metrics-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rf-metrics-actions[hidden],
#rf-metrics-body[hidden] {
  display: none !important;
}

.rf-metrics-group-title {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-top: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

.rf-metrics-group-title:first-child {
  margin-top: 0;
}

.rf-metrics-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.rf-metric-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface, #FAFAFA);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.rf-metric-option:hover {
  border-color: rgba(16, 185, 129, 0.45);
  background: #FFFFFF;
}

.rf-metric-option.is-active {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.06);
}

.rf-metric-option input[type="checkbox"] {
  width: 13.5px;
  height: 13.5px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.rf-option-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rf-option-title {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

@media (max-width: 960px) {
  .rf-search-col {
    flex: 1 1 100%;
  }
  .rf-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .pill-tray {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 640px) {
  .top-header {
    padding: 16px 14px 8px;
  }
  .rf-workspace {
    padding: 8px 12px 28px;
    gap: 12px;
  }
  .panel {
    padding: 14px 12px;
  }
  .rf-search-wrap {
    flex-wrap: wrap;
  }
  #rf-search-input {
    font-size: 16px;
    flex: 1 1 180px;
  }
  .rf-search-dropdown {
    right: 0;
  }
  .rf-toolbar-right {
    gap: 8px;
  }
  .rf-csv-btn {
    width: 100%;
    justify-content: center;
  }
  .rf-table th,
  .rf-table td {
    padding: 9px 10px;
    font-size: 12px;
  }
  .rf-table thead th.sticky-col,
  .rf-table tbody td.sticky-col {
    min-width: 132px;
    max-width: 155px;
    white-space: normal;
    line-height: 1.3;
  }
  .rf-metrics-checklist {
    grid-template-columns: 1fr;
  }
}
