:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --table-header-bg: #eef1f5;
  --text: #152033;
  --muted: #5f6b7c;
  --border: #d8e0ea;
  --accent: #0f62fe;
  --accent-dark: #0043ce;
  --success: #0e6027;
  --error: #a2191f;
  --shadow: 0 18px 50px rgba(21, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 98, 254, 0.12), transparent 28%),
    linear-gradient(180deg, #eef3fa 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--accent);
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.portfolio-page.container {
  width: min(1400px, calc(100% - 2rem));
  padding: 0.75rem 0 1.25rem;
}

.portfolio-page .hero {
  margin-bottom: 0.5rem;
}

.portfolio-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.portfolio-hero-copy {
  min-width: 0;
}

.portfolio-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.portfolio-share-wrap {
  position: relative;
}

.portfolio-share-panel {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 30;
  padding-top: 0.45rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.portfolio-share-panel-icons {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(21, 32, 51, 0.12);
}

.portfolio-share-wrap:hover .portfolio-share-panel,
.portfolio-share-wrap:focus-within .portfolio-share-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.portfolio-share-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.portfolio-share-option svg {
  width: 1rem;
  height: 1rem;
}

.portfolio-share-option:hover,
.portfolio-share-option:focus-visible {
  color: var(--accent);
  background: #f4f7fb;
}

.portfolio-action-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.portfolio-action-btn:hover:not(:disabled),
.portfolio-action-btn:focus-visible:not(:disabled) {
  background: #f4f7fb;
  color: var(--accent);
  border-color: rgba(15, 98, 254, 0.35);
}

.portfolio-action-btn.saved {
  color: var(--success);
  border-color: rgba(14, 96, 39, 0.35);
}

.portfolio-action-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.portfolio-action-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.portfolio-action-tooltip {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  width: max-content;
  max-width: 14rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(21, 32, 51, 0.12);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.portfolio-action-btn:hover .portfolio-action-tooltip,
.portfolio-action-btn:focus-visible .portfolio-action-tooltip,
.portfolio-action-btn.bookmark-feedback .portfolio-action-tooltip {
  opacity: 1;
  visibility: visible;
}

.portfolio-page .eyebrow {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.15;
}

.portfolio-page h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.05;
  margin: 0;
}

.portfolio-page .subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.portfolio-parse-notice {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(15, 98, 254, 0.22);
  border-radius: 8px;
  background: rgba(15, 98, 254, 0.06);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.portfolio-page .portfolio-overview {
  gap: 0.65rem;
}

.portfolio-page .portfolio-summary-card,
.portfolio-page .chart-card,
.portfolio-page .table-card {
  padding: 0.75rem 0.9rem;
}

.portfolio-page .chart-card {
  display: flex;
  flex-direction: column;
  padding-bottom: 0.55rem;
}

.portfolio-page .portfolio-data-card {
  margin-top: 0.65rem;
}

.portfolio-page .section-title {
  font-size: 1rem;
}

.portfolio-page .column-toggle-hint {
  margin: 0.2rem 0 0.4rem;
  font-size: 0.82rem;
  line-height: 1.3;
}

.hidden-columns-restore {
  color: var(--muted);
}

.hidden-columns-restore.hidden {
  display: none;
}

button.hidden-column-restore-btn,
button.hidden-column-restore-all-btn,
button.column-hide-undo-btn {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  line-height: inherit;
  cursor: pointer;
  white-space: nowrap;
}

button.hidden-column-restore-btn:hover:not(:disabled),
button.hidden-column-restore-all-btn:hover:not(:disabled),
button.column-hide-undo-btn:hover:not(:disabled),
button.hidden-column-restore-btn:focus-visible:not(:disabled),
button.hidden-column-restore-all-btn:focus-visible:not(:disabled),
button.column-hide-undo-btn:focus-visible:not(:disabled) {
  color: var(--accent);
  background: transparent;
  text-decoration: underline;
}

.column-hide-undo-toast {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.45rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  box-shadow: 0 4px 14px rgba(21, 32, 51, 0.08);
}

.column-hide-undo-toast.hidden {
  display: none;
}

.portfolio-page .portfolio-topline {
  gap: 1.25rem;
}

.portfolio-page .summary-value {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
}

.portfolio-page .chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 2.35rem;
  flex-shrink: 0;
}

.portfolio-page .chart-card-header-spacer {
  visibility: hidden;
  pointer-events: none;
}

.portfolio-page .chart-wrap {
  height: 220px;
  min-height: 220px;
  margin-top: 0;
  flex-shrink: 0;
  overflow: visible;
}

.portfolio-page .chart-custom-legend {
  position: relative;
  margin-top: 0.15rem;
  padding-right: 2rem;
}

.portfolio-page .chart-custom-legend.has-more:not(.is-expanded) {
  padding-bottom: 0.45rem;
}

.portfolio-page .chart-custom-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.12rem 0.85rem;
}

.portfolio-page .chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.15rem;
  color: var(--text);
  cursor: pointer;
}

button.chart-legend-item:hover:not(:disabled),
button.chart-legend-item:focus-visible {
  color: inherit;
  background: transparent;
}

.portfolio-page .chart-legend-swatch {
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(21, 32, 51, 0.12);
  flex-shrink: 0;
}

.portfolio-page .chart-custom-legend-expand {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0 0.2rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.portfolio-page .chart-custom-legend-expand:hover,
.portfolio-page .chart-custom-legend-expand:focus-visible {
  color: var(--accent);
}

.portfolio-page table th,
.portfolio-page table td {
  padding: 0.2rem 0.55rem;
  font-size: 0.88rem;
  line-height: 1.25;
}

.portfolio-page table th {
  font-size: 0.76rem;
  background: var(--table-header-bg);
}

.portfolio-page #portfolio-table thead th {
  background: var(--table-header-bg);
}

.portfolio-page #portfolio-table {
  border-collapse: separate;
  border-spacing: 0;
}

#portfolio-table-wrap:not(.column-toggle-row-collapsed) #portfolio-table thead tr.column-toggle-row th:first-child {
  border-top-left-radius: 6px;
}

#portfolio-table-wrap:not(.column-toggle-row-collapsed) #portfolio-table thead tr.column-toggle-row th:last-child {
  border-top-right-radius: 6px;
}

#portfolio-table-wrap.column-toggle-row-collapsed #portfolio-table thead tr.header-sort-row th:first-child {
  border-top-left-radius: 6px;
}

#portfolio-table-wrap.column-toggle-row-collapsed #portfolio-table thead tr.header-sort-row th:last-child {
  border-top-right-radius: 6px;
}

#portfolio-table thead tr.header-sort-row th:first-child {
  border-bottom-left-radius: 6px;
}

#portfolio-table thead tr.header-sort-row th:last-child {
  border-bottom-right-radius: 6px;
}

.portfolio-page #portfolio-table thead .column-toggle-row th {
  background: var(--surface);
}

.portfolio-page .column-toggle-row th {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.column-toggle-lead-cell {
  white-space: nowrap;
}

.column-toggle-collapse-btn {
  display: inline-block;
  margin: 0 0.2rem 0 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.column-toggle-collapse-btn:hover:not(:disabled),
.column-toggle-collapse-btn:focus-visible:not(:disabled) {
  color: var(--text);
  background: transparent;
}

.column-toggle-row-collapsed .column-toggle-row .column-toggle {
  display: none;
}

.column-toggle-row-collapsed .column-toggle-row th {
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
}

.column-toggle-row-collapsed .column-toggle-row th:not(.column-toggle-lead-cell) {
  font-size: 0;
  line-height: 0;
}

.sortable-col {
  vertical-align: bottom;
}

.sort-col-btn {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.15rem;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
  white-space: normal;
}

.sort-col-label {
  line-height: 1.25;
  word-break: break-word;
}

button.sort-col-btn:hover:not(:disabled),
button.sort-col-btn:focus-visible {
  color: inherit;
  background: transparent;
}

.sort-col-btn.sort-active {
  color: var(--text);
}

.sort-indicator {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.55rem;
  margin-top: 0.1rem;
  font-size: 0.55rem;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

.portfolio-page .sortable-col {
  padding: 0.2rem 0.55rem;
}

.portfolio-topnav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.portfolio-back-arrow {
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  color: var(--text);
}

.portfolio-back-arrow:hover {
  text-decoration: underline;
}

.portfolio-topnav .eyebrow {
  margin: 0;
}

.portfolio-page .back-link-wrap-bottom {
  margin: 0.65rem 0 0;
}

.portfolio-page ~ .site-footer {
  width: min(1400px, calc(100% - 2rem));
  padding: 0 0 1rem;
}

.extractor-page.container {
  padding: 0.75rem 0 1.25rem;
}

.extractor-page .hero {
  margin-bottom: 0.65rem;
}

.extractor-page h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
}

.extractor-page .subtitle {
  margin: 0.3rem 0 0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.extractor-page .upload-card,
.extractor-page .search-card,
.extractor-page .results-card {
  padding: 0.85rem 1rem;
}

.extractor-page .upload-card {
  margin-bottom: 0.65rem;
}

.extractor-page .section-title {
  font-size: 1rem;
}

.extractor-page .section-copy,
.extractor-page .upload-hint {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  line-height: 1.4;
}

.extractor-page .saved-portfolio-link-wrap {
  margin-top: 0.5rem;
}

.extractor-page .upload-form {
  margin-top: 0.65rem;
}

.extractor-page .search-form label {
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.extractor-page .status {
  margin: 0.5rem 0 0;
  min-height: 1.25rem;
}

.extractor-page .results-card {
  margin-top: 0.65rem;
}

.extractor-page .results-header {
  margin-bottom: 0.65rem;
}

.extractor-page .results-header h2 {
  font-size: 1.2rem;
}

.extractor-page .meta {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
}

.extractor-page .outlook-section {
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
}

.extractor-page .outlook-label {
  margin: 0.25rem 0 0.15rem;
  font-size: 1.15rem;
}

.extractor-page .trends-section {
  margin-bottom: 0.65rem;
}

.extractor-page .trends-title {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
}

.extractor-page .trends-grid {
  gap: 0.5rem;
}

.extractor-page .trend-card {
  padding: 0.55rem 0.65rem;
}

.extractor-page .trend-value {
  margin: 0.25rem 0 0.1rem;
  font-size: 1.05rem;
}

.extractor-page .footnote {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.extractor-page ~ .site-footer {
  padding: 0 0 1rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

.subtitle {
  max-width: 46rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.search-card {
  padding: 1.5rem;
}

.upload-card {
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.section-title {
  margin: 0;
  font-size: 1.15rem;
}

.section-copy,
.upload-hint {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.upload-form {
  margin-top: 1rem;
}

.upload-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.upload-row input[type="file"] {
  flex: 1;
  min-width: 0;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fafbfd;
}

.search-form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.search-row {
  display: flex;
  gap: 0.75rem;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  text-transform: uppercase;
}

input[type="text"]:focus {
  outline: 2px solid rgba(15, 98, 254, 0.25);
  border-color: var(--accent);
}

button {
  padding: 0.9rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.status {
  min-height: 1.5rem;
  margin: 0.85rem 0 0;
  color: var(--muted);
}

.status.loading {
  color: var(--accent);
}

.status.error {
  color: var(--error);
}

.results-card {
  margin-top: 1.25rem;
  padding: 1.5rem;
}

.hidden {
  display: none;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.results-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.outlook-section {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbfd;
}

.outlook-eyebrow {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.outlook-label {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.45rem;
  font-weight: 700;
}

.outlook-summary {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.outlook-section.growing {
  border-color: rgba(14, 96, 39, 0.25);
  background: rgba(14, 96, 39, 0.06);
}

.outlook-section.growing .outlook-label {
  color: var(--success);
}

.outlook-section.declining {
  border-color: rgba(162, 25, 31, 0.25);
  background: rgba(162, 25, 31, 0.06);
}

.outlook-section.declining .outlook-label {
  color: var(--error);
}

.outlook-section.stable {
  border-color: rgba(95, 107, 124, 0.25);
  background: rgba(95, 107, 124, 0.08);
}

.outlook-section.stable .outlook-label {
  color: var(--muted);
}

.outlook-section.unknown .outlook-label {
  color: var(--muted);
}

.trends-section {
  margin-bottom: 1.25rem;
}

.trends-title {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.trends-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.trend-card {
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbfd;
}

.trend-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.trend-value {
  margin: 0.45rem 0 0.2rem;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trend-direction {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.trend-card.growth {
  border-color: rgba(14, 96, 39, 0.25);
  background: rgba(14, 96, 39, 0.06);
}

.trend-card.growth .trend-value,
.trend-card.growth .trend-direction {
  color: var(--success);
}

.trend-card.decline {
  border-color: rgba(162, 25, 31, 0.25);
  background: rgba(162, 25, 31, 0.06);
}

.trend-card.decline .trend-value,
.trend-card.decline .trend-direction {
  color: var(--error);
}

.trend-card.neutral .trend-value,
.trend-card.neutral .trend-direction {
  color: var(--muted);
}

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

.portfolio-pinned-header {
  position: fixed;
  top: 0;
  z-index: 30;
  background: var(--table-header-bg);
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 10px rgba(21, 32, 51, 0.12);
  pointer-events: none;
  overflow: hidden;
}

.portfolio-pinned-header.hidden {
  display: none;
}

.portfolio-pinned-header-scroll {
  overflow: hidden;
}

.portfolio-pinned-header-table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.portfolio-pinned-header-table th {
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  line-height: 1.25;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--table-header-bg);
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}

.portfolio-pinned-header-table .column-toggle-row th {
  background: var(--surface);
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.portfolio-pinned-header-scroll:not(.column-toggle-row-collapsed) .portfolio-pinned-header-table thead tr.column-toggle-row th:first-child {
  border-top-left-radius: 6px;
}

.portfolio-pinned-header-scroll:not(.column-toggle-row-collapsed) .portfolio-pinned-header-table thead tr.column-toggle-row th:last-child {
  border-top-right-radius: 6px;
}

.portfolio-pinned-header-scroll.column-toggle-row-collapsed .portfolio-pinned-header-table thead tr.header-sort-row th:first-child {
  border-top-left-radius: 6px;
}

.portfolio-pinned-header-scroll.column-toggle-row-collapsed .portfolio-pinned-header-table thead tr.header-sort-row th:last-child {
  border-top-right-radius: 6px;
}

.portfolio-pinned-header-table thead tr.header-sort-row th:first-child {
  border-bottom-left-radius: 6px;
}

.portfolio-pinned-header-table thead tr.header-sort-row th:last-child {
  border-bottom-right-radius: 6px;
}

.portfolio-pinned-header-table .sort-col-btn {
  pointer-events: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.45rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

td {
  font-variant-numeric: tabular-nums;
}

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

.footnote {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.portfolio-summary-card,
.chart-card,
.table-card {
  padding: 1.5rem;
}

.portfolio-overview {
  display: grid;
  grid-template-columns: minmax(220px, 280px) repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
}

.portfolio-overview-no-chart {
  grid-template-columns: minmax(220px, 280px);
}

.portfolio-summary-card {
  display: flex;
  align-items: center;
}

.portfolio-topline {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  width: 100%;
}

.summary-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.summary-value {
  margin: 0.35rem 0 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.portfolio-data-card {
  margin-top: 1rem;
}

.column-toggle-hint {
  margin: 0.35rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.column-toggle-row th {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  background: var(--surface);
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.column-toggle input {
  margin: 0;
  cursor: pointer;
}

.column-hidden {
  display: none;
}

.sticky-col-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.pin-header-controls {
  margin-top: 0.35rem;
  padding-top: 0;
  border-top: none;
}

.sticky-col-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.sticky-col-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f4f7fb;
}

.sticky-col-toggle-btn {
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.sticky-col-toggle-btn:hover:not(:disabled),
.sticky-col-toggle-btn:focus-visible:not(:disabled) {
  background: transparent;
  color: var(--muted);
}

.sticky-col-toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(21, 32, 51, 0.12);
}

.sticky-col-toggle-btn.active:hover:not(:disabled),
.sticky-col-toggle-btn.active:focus-visible:not(:disabled) {
  background: var(--surface);
  color: var(--text);
}

.sticky-col-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sticky-cols-active #portfolio-table {
  border-collapse: separate;
  border-spacing: 0;
}

#portfolio-table .sticky-col {
  position: sticky;
  background: var(--surface);
  z-index: 2;
}

#portfolio-table thead .sticky-col {
  z-index: 4;
  background: var(--table-header-bg);
}

#portfolio-table thead .column-toggle-row .sticky-col {
  background: var(--surface);
}

#portfolio-table .sticky-col-edge {
  position: sticky;
}

#portfolio-table .sticky-col-edge::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(100%);
  box-shadow: 4px 0 8px rgba(21, 32, 51, 0.1);
  pointer-events: none;
}

.portfolio-page .sticky-col-controls {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
}

.portfolio-page .sticky-col-label {
  font-size: 0.78rem;
}

.portfolio-page .sticky-col-toggle-btn {
  padding: 0.28rem 0.6rem;
  font-size: 0.78rem;
}

.chart-card .section-title {
  margin-bottom: 0;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.gain-loss-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f4f7fb;
}

.gain-loss-toggle-btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.gain-loss-toggle-btn:hover:not(:disabled),
.gain-loss-toggle-btn:focus-visible:not(:disabled) {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.gain-loss-toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(21, 32, 51, 0.12);
}

.gain-loss-toggle-btn.active:hover:not(:disabled),
.gain-loss-toggle-btn.active:focus-visible:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  text-decoration: underline;
}

.gain-loss-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chart-card-losses {
  border-color: rgba(162, 25, 31, 0.18);
}

.chart-card-gains {
  border-color: rgba(25, 128, 56, 0.22);
}

.status-col {
  min-width: 7.5rem;
}

td.status-col,
.status-cell {
  white-space: nowrap;
}

.status-cell {
  display: inline-block;
  min-width: 4.5rem;
}

.status-loading {
  color: var(--muted);
}

.status-link {
  padding: 0.2rem 0.55rem;
  border: none;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.status-link.status-growing:hover,
.status-link.status-growing:focus-visible {
  background: rgba(14, 96, 39, 0.22);
  color: #0e6027;
}

.status-link.status-stable:hover,
.status-link.status-stable:focus-visible {
  background: rgba(95, 107, 124, 0.22);
  color: #3d4654;
}

.status-link.status-declining:hover,
.status-link.status-declining:focus-visible {
  background: rgba(162, 25, 31, 0.22);
  color: #a2191f;
}

.status-growing {
  background: rgba(14, 96, 39, 0.12);
  color: var(--success);
}

.status-stable {
  background: rgba(95, 107, 124, 0.14);
  color: var(--muted);
}

.status-declining {
  background: rgba(162, 25, 31, 0.12);
  color: var(--error);
}

#portfolio-table td.pinned-highlight-growing {
  background-color: #d4ebdc !important;
  color: #0e6027;
  font-weight: 700;
}

#portfolio-table td.pinned-highlight-stable {
  background-color: #e6e9ee !important;
  color: #3d4654;
  font-weight: 700;
}

#portfolio-table td.pinned-highlight-declining {
  background-color: #f7d4d7 !important;
  color: #a2191f;
  font-weight: 700;
}

#portfolio-table td.sticky-col.pinned-highlight-growing,
#portfolio-table td.sticky-col.pinned-highlight-stable,
#portfolio-table td.sticky-col.pinned-highlight-declining {
  background-clip: padding-box;
}

#portfolio-table td.row-status-hover-highlight {
  font-weight: 700;
  background-color: #f3f5f8;
}

.status-tooltip {
  position: fixed;
  z-index: 1100;
  width: min(22rem, calc(100vw - 1.5rem));
  max-width: calc(100vw - 1.5rem);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(21, 32, 51, 0.16);
  pointer-events: none;
  transform: translate(-50%, -100%);
  box-sizing: border-box;
}

.status-tooltip.hidden {
  display: none;
}

.status-tooltip-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
}

.status-tooltip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.status-tooltip .trend-card {
  padding: 0.45rem 0.35rem;
  border-radius: 999px;
  text-align: center;
}

.status-tooltip .trend-label {
  font-size: 0.58rem;
  line-height: 1.2;
}

.status-tooltip .trend-value {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.15;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 32, 51, 0.45);
}

.modal-dialog {
  position: relative;
  width: min(920px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  margin: 1rem auto;
  padding: 1.25rem 1.5rem 1.5rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.modal-section-title {
  margin: 1rem 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.modal-trends-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-wrap {
  position: relative;
  height: 280px;
  margin-top: 0.75rem;
}

.chart-legend-tooltip {
  position: fixed;
  z-index: 1200;
  max-width: min(20rem, calc(100vw - 1.5rem));
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(21, 32, 51, 0.18);
  pointer-events: none;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  transform: translate(-50%, -100%);
}

.chart-legend-tooltip.hidden {
  display: none;
}

.back-link-wrap {
  margin: 1.25rem 0 0;
}

.back-link {
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.site-footer {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0 0 2rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  .container {
    width: min(100%, calc(100% - 1rem));
    padding-top: 1.5rem;
  }

  .portfolio-page.container {
    padding-top: 0.5rem;
  }

  .extractor-page.container {
    padding-top: 0.5rem;
  }

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

  .upload-row,
  .search-row {
    flex-direction: column;
  }

  .portfolio-overview {
    grid-template-columns: 1fr;
  }

  .portfolio-page .chart-wrap,
  .chart-wrap {
    height: 210px;
    min-height: 210px;
  }

  button:not(.portfolio-action-btn) {
    width: 100%;
  }
}
