:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(10, 24, 43, 0.94);
  --panel-alt: #12263d;
  --text: #f3f7ff;
  --muted: #95a8c6;
  --accent: #43d0b4;
  --accent-2: #43d0b4;
  /* --accent-2: #8d7cf6; */
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --surface: rgba(255,255,255,0.04);
  --surface-strong: rgba(255,255,255,0.08);
  --button-text: #03111d;
}

body.light-theme {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-alt: #eaf2ff;
  --text: #122033;
  --muted: #516276;
  --accent: #1f9d87;
  /* --accent-2: #6c5ce7; */
  --accent-2: #1f9d87;
  --border: rgba(18, 32, 51, 0.12);
  --shadow: 0 20px 60px rgba(15, 30, 60, 0.14);
  --surface: rgba(18, 32, 51, 0.04);
  --surface-strong: rgba(18, 32, 51, 0.08);
  --button-text: #ffffff;
}

body.blue-theme {
  color-scheme: light;
  --bg: #dfecf4;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-alt: #c6e0e8;
  --text: #132435;
  --muted: #55697a;
  --accent: #38748a;
  --accent-2: #7aa8b8;
  --border: rgba(19, 36, 53, 0.12);
  --shadow: 0 20px 60px rgba(32, 67, 84, 0.14);
  --surface: rgba(255, 255, 255, 0.42);
  --surface-strong: rgba(19, 36, 53, 0.08);
  --button-text: #ffffff;
}

* { box-sizing: border-box; }

body > .app-shell:first-of-type {
  display: none;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--bg) 78%, var(--panel-alt)));
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.app-shell {
  min-height: 100vh;
  padding: 1rem;
}
.topbar {
  max-width: 1200px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(7, 18, 32, 0.75);
  backdrop-filter: blur(10px);
}
body.blue-theme .topbar {
  background: linear-gradient(to bottom, #ffffff 0%, #EDF1F3 50%, #ffffff 100%); /* #EDF1F3 #e4eaed 100%);*/
}
body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.78);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.brand-subtitle {
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-subtitle-icon {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.brand-subtitle-link {
  cursor: pointer;
}

.brand-subtitle-link:hover,
.brand-subtitle-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

.brand-subtitle-link:hover .brand-subtitle-icon {
  transform: rotate(45deg);
}

.brand-muted {
  opacity: 0.56;
  font-weight: 500;
  font-size: 0.88em;
}

.brand-strong {
  opacity: 1;
  font-weight: 800;
  font-size: 1.4em;
}
.nav-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.nav-pill, .primary-btn, .secondary-btn, .chip, .theme-trigger, .theme-option {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 1rem;
  height: 36px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.nav-pill:hover, .primary-btn:hover, .secondary-btn:hover, .chip:hover, .theme-trigger:hover, .theme-option:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--button-text);
  font-weight: 700;
}
.secondary-btn {
  background: var(--surface);
  color: var(--text);
}
.theme-picker {
  position: relative;
}

.theme-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: var(--surface);
  padding: 0;
}

.theme-trigger-icon,
.theme-option-icon {
  display: block;
  width: 1.8rem;
  height: 1.8rem;
}

.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  display: grid;
  gap: 0.35rem;
  min-width: 11rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 20;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-radius: 14px;
}

.theme-option.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(67, 208, 180, 0.12);
}

.theme-option span {
  flex: 1;
}
.content {
  max-width: 1200px;
  margin: 0 auto;
}
.hero-card, .auth-card, .panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero-card {
  padding: 1.25rem 1.4rem;
  display: grid;
  gap: 0.9rem;
}
.hero-title {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
  margin: 0;
}
.hero-copy {
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 680px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.transactions-hero-actions {
  justify-content: flex-start;
}

.upload-hero-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}
.metrics-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.metric {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  background: var(--surface);
}
.metric strong { display: block; font-size: 1.2rem; margin-bottom: 0.35rem; }
.metric span { color: var(--muted); font-size: 0.95rem; }
.feature-list {
  display: grid;
  gap: 0.75rem;
}
.feature-item {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: var(--surface);
}
.feature-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.auth-shell {
  display: grid;
  gap: 1rem;
}
.auth-card {
  padding: 1.25rem;
}
.auth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.auth-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip.active {
  background: rgba(67, 208, 180, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.form-grid {
  display: grid;
  gap: 0.85rem;
}
.field {
  display: grid;
  gap: 0.35rem;
}
.field label {
  font-size: 0.92rem;
  color: var(--muted);
}
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: var(--surface);
  color: var(--text);
}

/* Make date inputs match the compact select height used in portfolio selector */
.field input[type="date"] {
  height: 36px;
  padding: 0 0.95rem;
}
.field select {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 0.95rem;
  height: 36px;
  line-height: normal;
  background: var(--surface);
  color: var(--text);
}
.field input:focus {
  outline: 2px solid rgba(67,208,180,0.35);
  border-color: var(--accent);
}
.field select:focus {
  outline: 2px solid rgba(67,208,180,0.35);
  border-color: var(--accent);
}
.field.invalid input {
  border-color: #ff6b7d;
  box-shadow: 0 0 0 2px rgba(255, 107, 125, 0.18);
}
.field.invalid select,
.field.invalid textarea {
  border-color: #ff6b7d;
  box-shadow: 0 0 0 2px rgba(255, 107, 125, 0.18);
}
.field.invalid label,
.field.invalid > span,
.field.invalid span {
  color: #e85a6c;
}
.error-message {
  color: #e85a6c;
  font-size: 0.85rem;
}
.status-message {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  font-size: 0.95rem;
  margin-top: 1rem;
}
.status-message.success {
  background: rgba(67, 208, 180, 0.16);
  color: #2f9e44;
}
.status-message.error {
  background: rgba(255, 107, 125, 0.16);
  color: #e85a6c;
}
.upload-status-hint {
  margin: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.panel-card {
  padding: 1.15rem;
}

.portfolios-panel-card {
  display: grid;
  gap: 1rem;
}

.portfolios-header-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.portfolios-header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: flex-end;
}

.portfolios-header-row .hero-title {
  margin: 0;
}

.portfolios-panel-title {
  line-height: 1.1;
}

.portfolios-header-selection {
  min-width: 270px;
  max-width: 360px;
}

.portfolios-header-selection .field {
  margin: 0;
}

.portfolios-header-selection .field > span {
  text-align: right;
}

.portfolios-actions-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.portfolios-mode-subtitle {
  margin: -0.15rem 0 0;
  font-size: 0.95rem;
}

.portfolios-header-actions-row {
  margin-top: 0;
}

.valuations-panel-card {
  display: grid;
  gap: 0.9rem;
}

.valuations-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.valuations-filters-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: start;
}

.valuations-mode-field {
  justify-self: end;
  align-self: start;
}

.valuations-filter-field {
  margin: 0;
}

.valuations-header-selection-inline {
  min-width: 270px;
  max-width: 360px;
}

.valuations-header-selection-inline .field {
  margin: 0;
}

.valuations-actions-row {
  align-items: center;
}

.valuations-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.valuations-calculate-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

.valuations-calculate-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  background: rgba(2, 8, 16, 0.55);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.valuations-calculate-popup {
  width: min(44rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1rem 1.05rem;
  display: grid;
  gap: 0.85rem;
}

.valuations-calculate-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.valuations-calculate-field {
  margin: 0;
}

.valuations-calculate-result {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 0.7rem 0.75rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
}

.valuations-table {
  width: 100%;
  border-collapse: collapse;
}

.valuations-table th,
.valuations-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.75rem;
}

.valuations-table th {
  text-align: left;
}

.valuations-table th.valuations-cell-number {
  text-align: right;
}

.valuations-cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.valuations-summary-column {
  white-space: nowrap;
  width: 8.5rem;
  min-width: 8.5rem;
  max-width: 8.5rem;
}

.valuations-date-column {
  white-space: nowrap;
  min-width: 6rem;
}

.valuations-total-positive {
  color: #2f9e44;
  font-weight: 700;
}

.valuations-total-negative {
  color: #e85a6c;
  font-weight: 700;
}

.valuations-total-neutral {
  color: var(--muted);
  font-weight: 700;
}

.valuations-table tbody tr:last-child td {
  border-bottom: none;
}

.performance-chart-shell {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.performance-chart-metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.performance-chart-metric {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.performance-chart-metric strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.performance-chart-metric-align-right {
  margin-left: auto;
}

.performance-chart-metric-group-right {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.performance-chart-metric-content-right {
  justify-items: end;
  text-align: right;
}

.performance-metric-amber {
  color: #f0a020;
  font-weight: 700;
}

.performance-chart-canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 76%, transparent), color-mix(in srgb, var(--surface) 86%, transparent));
  overflow: hidden;
}

.performance-chart-canvas {
  width: 100%;
  min-height: 220px;
}

.performance-chart-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.growth-metric-poc {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-top: 1px solid var(--border);
}

.growth-metric-poc-group {
  flex: 1 1 24rem;
  min-width: 20rem;
  padding: 0.75rem 0.85rem 0.85rem;
}

.growth-metric-poc-group + .growth-metric-poc-group {
  border-left: 1px solid var(--border);
}

.growth-metric-poc-title {
  margin: 0 0 0.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.growth-metric-poc-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.quality-metric-poc .growth-metric-poc-items {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.growth-metric-poc-item {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  text-align: center;
}

.growth-metric-poc-item strong {
  font-size: 0.96rem;
  font-variant-numeric: tabular-nums;
}

.shared-segmented-control {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.shared-segmented-divider {
  width: 1px;
  background: var(--border);
}

.shared-segmented-option {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  min-width: 3.05rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.shared-segmented-option:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
}

.shared-segmented-option.active {
  color: var(--button-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.date-range-selector {
  overflow: visible;
}

.date-range-selector > .shared-segmented-option:first-child {
  border-radius: 999px 0 0 999px;
}

.date-range-selector > .shared-segmented-option:last-child {
  border-radius: 0 999px 999px 0;
}

.date-range-selector-custom {
  position: relative;
}

.date-range-selector-popover {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.45rem);
  left: 50%;
  display: grid;
  gap: 0.6rem;
  width: max-content;
  min-width: 18rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

.date-range-selector-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
}

.date-range-selector-inputs input {
  min-width: 0;
  height: 36px;
  padding: 0 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.performance-header-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.8rem;
}

.performance-header-row > h3 {
  justify-self: start;
}

.performance-header-row > .portfolios-actions-row {
  justify-self: end;
}

.performance-header-actions {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 0.5rem;
}

.positions-header-actions {
  display: inline-flex;
  align-items: center;
  grid-column: -2 / -1;
  justify-self: end;
  gap: 0.5rem;
}

/* Prevent labels on the positions header buttons from wrapping */
.positions-header-actions .secondary-btn,
.positions-header-actions button {
  white-space: nowrap;
}

.positions-date-field input[type="date"] {
  box-sizing: border-box;
  height: 36px;
  line-height: normal;
  padding: 0 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.positions-chart-wrap {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 76%, transparent), color-mix(in srgb, var(--surface) 86%, transparent));
  overflow: hidden;
  padding: 0.75rem;
}

.positions-pie-canvas {
  width: 100%;
  min-height: 330px;
}

.performance-absolute-iir-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
}

.performance-absolute-iir-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.portfolio-cash-position-field {
  justify-items: start;
}

.portfolio-cash-position-toggle {
  justify-self: start;
}

.portfolio-cash-position-notes {
  margin: 0.2rem 0 0 1.35rem;
  padding-left: 0.9rem;
}

.portfolio-cash-position-notes li + li {
  margin-top: 0.2rem;
}

.performance-absolute-iir-help {
  position: relative;
}

.performance-absolute-iir-help-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.performance-absolute-iir-help-btn:hover,
.performance-absolute-iir-help-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.valuations-expand-btn-glyph {
  display: block;
  line-height: 1;
  transform: translateY(-0.04em);
}

.performance-absolute-iir-help-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 0.85rem;
}

.performance-absolute-iir-help-panel p {
  margin: 0.45rem 0 0;
}

/* Ensure help panel title and text are left aligned and use consistent font sizing */
.performance-absolute-iir-help-panel strong {
  display: block;
  text-align: left;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.2;
}

.performance-absolute-iir-help-panel p {
  text-align: left;
}

/* Ensure help panel paragraphs use normal weight to avoid inheriting table header bold */
.performance-absolute-iir-help-panel p {
  font-weight: 400;
}

.performance-header-row > .secondary-btn {
  justify-self: end;
}

.performance-range-segmented {
  justify-self: center;
}


.transactions-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.transactions-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.upload-panel {
  display: grid;
  gap: 0.9rem;
}

.upload-panel-degiro {
  position: relative;
}

.guidance {
  display: grid;
  gap: 0.7rem;
}

.guidance-table {
  min-width: 720px;
}

.guidance-table td ul,
.guidance-table td ol {
  margin: 0;
  padding: 0;
  list-style-position: inside;
}

.guidance-table td li {
  margin: 0.1rem 0;
}

.upload-warning-box {
  border: 1px solid rgba(232, 90, 108, 0.55);
  border-radius: 12px;
  background: rgba(232, 90, 108, 0.14);
  color: #8b1d2e;
  padding: 0.7rem 0.8rem;
  display: grid;
  gap: 0.35rem;
}

.upload-warning-box strong {
  color: #8b1d2e;
}

.upload-warning-box p {
  margin: 0;
}

.upload-warning-box ul {
  margin: 0;
  padding-left: 1.2rem;
  color: #8b1d2e;
}

.upload-warning-box li {
  margin: 0.15rem 0;
  color: #8b1d2e;
}

.upload-panel h3 {
  margin: 0;
}

.upload-help-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.upload-help-icon-btn {
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.upload-help-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-help-icon-btn:focus-visible {
  outline: 2px solid rgba(67,208,180,0.35);
  outline-offset: 2px;
}

.upload-sample-and-help {
  display: grid;
  gap: 0.15rem;
}

.upload-column-help {
  margin-top: 0;
}

.upload-sample-row {
  margin-top: 0;
  margin-bottom: 0;
}

/* Cash row distinctive styling */
.positions-row-cash {
  background-color: rgba(255, 236, 153, 0.18);
  font-weight: 600;
}

.positions-row-cash td {
  border-top: 1px dashed rgba(0,0,0,0.06);
}

.positions-row-total td {
  border-top: 1px solid rgba(8, 24, 21, 0.98);
  background-color: rgba(67,208,180,0.06);
}

.valuations-table tbody tr.positions-row-clickable {
  cursor: pointer;
}

.valuations-table tbody tr.positions-row-clickable:hover {
  background: var(--surface-strong);
}

.upload-code-box {
  margin: 0;
  background: #f2f2f2;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  white-space: pre;
}

.upload-column-help-table {
  min-width: 720px;
}

.upload-column-help-table td,
.upload-column-help-table th {
  white-space: nowrap;
}

.upload-column-help-table td:nth-child(2),
.upload-column-help-table th:nth-child(2) {
  white-space: normal;
  min-width: 260px;
}

.upload-column-help-table td:nth-child(4),
.upload-column-help-table th:nth-child(4) {
  text-align: center;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upload-panel-degiro .upload-panel-header {
  padding-right: 6rem;
}

.upload-vendor-icon {
  display: block;
}

.upload-panel-degiro .upload-vendor-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.upload-vendor-logo {
  width: 7rem;
  height: auto;
  object-fit: contain;
}

.upload-hero-card .hero-copy {
  max-width: none;
}

.upload-custom-selectors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: start;
}

.upload-custom-selectors .field {
  align-content: start;
}

.upload-ordering-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 0.9rem;
  align-items: start;
}

.upload-box-title {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-order-box,
.upload-add-box {
  min-height: 72px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 0.55rem;
  background: var(--surface);
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-content: flex-start;
}

.upload-drop-slot {
  width: 0;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.upload-drop-slot.active {
  width: auto;
}

.upload-order-box.disabled {
  opacity: 0.6;
}

.upload-order-box.invalid {
  border-color: #ff6b7d;
  box-shadow: 0 0 0 2px rgba(255, 107, 125, 0.18);
}

.upload-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: rgba(67, 208, 180, 0.12);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  cursor: grab;
}

.upload-pill:active {
  cursor: grabbing;
}

.upload-pill-dragging {
  opacity: 0.45;
}

.upload-drop-placeholder {
  border-style: dashed;
  border-color: rgba(90, 165, 255, 0.85);
  background: rgba(90, 165, 255, 0.2);
  color: color-mix(in srgb, var(--text) 88%, #0b2f66);
  font-weight: 600;
}

.upload-pill-remove {
  width: 1.2rem;
  height: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.upload-pill-remove:hover {
  background: color-mix(in srgb, var(--surface-strong) 72%, white);
  border-color: color-mix(in srgb, var(--border) 68%, var(--text));
}

.upload-pill-add {
  background: rgba(67, 208, 180, 0.12);
}

.upload-pill-ignore {
  background: rgba(255, 186, 90, 0.22);
  border-color: rgba(255, 186, 90, 0.55);
  color: color-mix(in srgb, var(--text) 86%, #332100);
}

.upload-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.upload-input-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.upload-preview {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  background: var(--surface);
  display: grid;
  gap: 0.6rem;
}

.upload-preview h4 {
  margin: 0;
  font-size: 0.96rem;
}

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.upload-preview-cell {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.55rem;
  background: var(--surface-strong);
  display: grid;
  gap: 0.2rem;
}

.upload-preview-cell-ignore {
  background: rgba(255, 186, 90, 0.22);
  border-color: rgba(255, 186, 90, 0.55);
}

.upload-preview-cell-ignore .upload-preview-label,
.upload-preview-cell-ignore strong {
  color: color-mix(in srgb, var(--text) 86%, #332100);
}

.upload-preview-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.upload-textarea {
  min-height: 130px;
  resize: vertical;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  background: var(--surface);
  color: var(--text);
}

.upload-textarea:focus {
  outline: 2px solid rgba(67,208,180,0.35);
  border-color: var(--accent);
}

.valuations-upload-textarea {
  min-height: 170px;
}

.upload-note {
  margin: 0;
}

.upload-degiro-preview {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  background: var(--surface);
  display: grid;
  gap: 0.6rem;
}

.upload-degiro-preview h4 {
  margin: 0;
  font-size: 0.96rem;
}

.upload-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.upload-parse-failures {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
}

.upload-parse-failures-raw {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 0.65rem 0.7rem;
  max-height: 220px;
  overflow: auto;
  white-space: pre;
  font-size: 0.82rem;
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

/* Guidance tables (small helper tables) should be responsive and wrap content */
.transactions-table.guidance-table {
  min-width: 0;
  table-layout: auto;
  width: 100%;
}

.transactions-table.guidance-table th,
.transactions-table.guidance-table td {
  white-space: normal;
  word-break: break-word;
}

/* Ensure guidance tables in transactions layout have proper list indentation */
.transactions-table.guidance-table td ul,
.transactions-table.guidance-table td ol {
  margin: 0 0 0.5rem 0;
  padding-left: 1.2rem;
  list-style-position: outside;
}

.transactions-table.guidance-table td ul ul,
.transactions-table.guidance-table td ol ol,
.transactions-table.guidance-table td ul ol,
.transactions-table.guidance-table td ol ul {
  padding-left: 1.2rem;
}

.transactions-table th,
.transactions-table td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.transactions-table th {
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.transactions-table tbody tr:hover {
  background: var(--surface-strong);
}

.transactions-table tbody tr.upload-combined-transaction-row {
  background: rgba(67, 208, 180, 0.14);
}

.transactions-table tbody tr.upload-combined-transaction-row:hover {
  background: rgba(67, 208, 180, 0.22);
}

.transactions-table tbody tr.upload-unmapped-transaction-row {
  background: rgba(232, 90, 108, 0.14);
}

.transactions-table tbody tr.upload-unmapped-transaction-row:hover {
  background: rgba(232, 90, 108, 0.22);
}

.txn-summary-row-expandable {
  cursor: pointer;
}

.txn-summary-row-expandable[aria-expanded='true'] {
  background: rgba(67, 208, 180, 0.14);
}

.txn-summary-row-expandable[aria-expanded='true']:hover {
  background: rgba(67, 208, 180, 0.18);
}

.txn-summary-row-expandable:focus-visible {
  outline: 2px solid rgba(67,208,180,0.45);
  outline-offset: -2px;
}

.transactions-table td.txn-cell-amount,
.transactions-table th.txn-cell-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.transactions-table td.txn-cell-amount-positive {
  color: #2f9e44;
  font-weight: 600;
}

.transactions-table td.txn-cell-amount-negative {
  color: #e85a6c;
  font-weight: 600;
}

.upload-combined-legend {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-combined-legend-swatch {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: rgba(67, 208, 180, 0.22);
  flex: 0 0 auto;
}

.valuations-moved-date-swatch {
  border-color: rgba(255, 186, 90, 0.75);
  background: rgba(255, 186, 90, 0.3);
}

.valuations-moved-date-row {
  background: rgba(255, 186, 90, 0.2);
}

.valuations-moved-date-row:hover {
  background: rgba(255, 186, 90, 0.28);
}

.valuations-moved-date-note {
  font-size: 0.85rem;
}

.upload-bypass-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.screen-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(2, 8, 16, 0.55);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
}

.screen-loading-card {
  min-width: min(28rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  text-align: center;
}

.screen-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.inline-loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.inline-loading-indicator .screen-loading-spinner {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
  flex: 0 0 auto;
}

.performance-loading-wrap {
  display: flex;
  justify-content: center;
}

.performance-loading-indicator {
  justify-content: center;
}

.valuations-loading-cell {
  text-align: center;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


.txn-expand-column {
  width: 2.25rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  text-align: center;
}

.txn-expand-toggle,
.txn-expand-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
}

.txn-expand-arrow {
  width: 0.5rem;
  height: 0.5rem;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.txn-expand-arrow-open {
  transform: rotate(135deg);
}

.txn-summary-row-expandable:hover .txn-expand-arrow,
.txn-summary-row-expandable:focus-visible .txn-expand-arrow {
  border-color: color-mix(in srgb, var(--accent) 78%, white);
}

.txn-expanded-row td {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.txn-expanded-panel {
  padding: 0.85rem 0.9rem;
  background: color-mix(in srgb, rgba(67, 208, 180, 0.16) 45%, var(--surface-strong));
}

.valuation-positions-panel {
  display: grid;
  gap: 0.75rem;
}

.valuation-positions-grid-wrap {
  border-radius: 12px;
}

.valuation-positions-table {
  min-width: 860px;
}

.valuation-positions-table th {
  white-space: nowrap;
}

.valuation-positions-table td {
  padding: 0.8rem 0.85rem;
}

.valuation-positions-group-title {
  text-align: center !important;
}

.valuation-position-index {
  width: 2.25rem;
  text-align: right;
}

.valuation-position-logo-cell {
  width: 2.8rem;
}

.valuation-position-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
}

.valuation-position-portfolio-cell {
  vertical-align: top;
  font-weight: 600;
}

.valuation-positions-table tbody tr.valuation-position-group-start td {
  border-top: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}

.valuation-positions-table tbody tr.valuation-position-total-row td {
  border-top: 1px dashed color-mix(in srgb, var(--accent) 30%, var(--border));
  background: color-mix(in srgb, var(--surface-strong) 65%, transparent);
}

.valuation-position-total-label {
  font-weight: 700;
}

.valuation-position-total-value {
  font-weight: 700;
}

.valuation-position-meta,
.valuation-position-subvalue {
  font-size: 0.8em;
}

.txn-details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem 0.8rem;
}

.txn-details-row {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.txn-details-row .muted {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.txn-details-row strong {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-card ul { padding-left: 1rem; color: var(--muted); }
.muted { color: var(--muted); }
.footer-note {
  text-align: center;
  color: var(--muted);
  margin-top: 1rem;
}

.securities-details-pre {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.7rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.82rem;
}

.securities-details-table {
  min-width: 680px;
}

.securities-page-shell {
  margin-top: 0.5rem;
}

.securities-hero-card {
  align-items: start;
}

.securities-hero-copy-block {
  min-width: 0;
}

.securities-hero-title {
  font-size: clamp(1.8rem, 2.4vw, 2.4rem);
}

.securities-search-form {
  align-self: start;
}

.securities-search-form .field input[type="text"] {
  box-sizing: border-box;
  height: 36px;
  padding: 0 0.95rem;
}

.securities-search-actions {
  justify-content: flex-end;
}

.securities-results-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.securities-results-title {
  margin: 0;
}

.securities-results-meta {
  margin: 0;
  font-size: 0.92rem;
}

.securities-results-table th:nth-child(2),
.securities-results-table td:nth-child(2) {
  min-width: 88px;
}

.securities-results-table th:nth-child(3),
.securities-results-table td:nth-child(3) {
  min-width: 128px;
}

.securities-results-table th:last-child,
.securities-results-table td:last-child {
  white-space: nowrap;
  width: 110px;
}

.securities-local-copy-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.securities-local-copy-chip-present {
  color: #2f9e44;
  background: rgba(67, 208, 180, 0.18);
  border: 1px solid rgba(67, 208, 180, 0.38);
}

.securities-local-copy-chip-missing {
  color: #b54708;
  background: rgba(255, 186, 90, 0.22);
  border: 1px solid rgba(255, 186, 90, 0.45);
}

@media (min-width: 900px) {
  .valuations-header-selection {
    justify-self: end;
  }

  .valuations-header-row.performance-header-row .valuations-actions-row {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .hero-card {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
  }
  .securities-hero-card {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .transactions-hero-card {
    align-items: start;
  }
  .transactions-hero-actions {
    align-self: start;
    justify-content: flex-end;
    width: 100%;
  }
  .upload-hero-actions {
    align-self: start;
    width: 100%;
    margin-top: 1rem;
  }

  .securities-search-form {
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: end;
    column-gap: 0.8rem;
  }

  .securities-search-form .hero-actions {
    grid-column: 1 / -1;
  }

  .securities-search-form .primary-btn {
    margin-left: auto;
  }

  .auth-shell.desktop-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

@media (max-width: 899px) {
  .valuations-filters-row {
    grid-template-columns: 1fr;
  }
  .app-shell { padding: 0.75rem; }
  .topbar {
    border-radius: 20px;
    flex-direction: column;
    gap: 0.75rem;
  }
  /* When the topbar stacks in narrow viewports, center the brand rows */
  .topbar .brand {
    align-items: center;
    text-align: center;
  }
  .theme-menu {
    right: auto;
    left: 0;
  }
  .transactions-filters {
    grid-template-columns: 1fr;
  }
  .upload-custom-selectors,
  .upload-input-grid,
  .upload-ordering-layout {
    grid-template-columns: 1fr;
  }
  .securities-search-actions {
    justify-content: stretch;
  }
  .securities-search-actions .primary-btn {
    width: 100%;
  }
  .upload-preview-grid {
    grid-template-columns: 1fr;
  }
  .txn-details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portfolios-header-row {
    flex-direction: column;
  }
  .portfolios-header-controls {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .portfolios-header-actions-row {
    margin-top: 0;
  }
  .portfolios-header-selection {
    min-width: 100%;
    max-width: none;
  }

  .valuations-header-selection-inline {
    min-width: 100%;
    max-width: none;
    width: 100%;
  }

  .valuations-header-selection-inline .field {
    width: 100%;
  }

  .valuations-calculate-fields {
    grid-template-columns: 1fr;
  }
  .metrics-grid { grid-template-columns: 1fr; }

  .performance-chart-canvas {
    min-height: 200px;
  }

  .performance-header-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .performance-header-row > .portfolios-actions-row {
    justify-self: start;
  }

  .performance-header-row > .secondary-btn {
    justify-self: start;
  }

  .performance-range-segmented {
    justify-self: start;
  }

  .growth-metric-poc-group {
    flex-basis: 100%;
    min-width: 0;
  }

  .growth-metric-poc-group + .growth-metric-poc-group {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .txn-details-grid {
    grid-template-columns: 1fr;
  }

  .growth-metric-poc-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quality-metric-poc .growth-metric-poc-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
