/* ============================================
   V2 COMPARE TOOL
   Security comparison page styles
   ============================================ */

#v2-compare-tool.v2-tool-pane.active {
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
  height: 100%;
}

/* Page container */
.v2-ct {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-elev, #F3F4F6);
}

/* Header */
.v2-ct__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border, #E5E7EB);
  flex-wrap: wrap;
  gap: 12px;
}

.v2-ct__header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.v2-ct__header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.v2-ct__title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-ct__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #1F2937);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-ct__title i {
  font-size: 18px;
  color: var(--accent, #0964A0);
}

.v2-ct__subtitle {
  font-size: 12px;
  color: var(--text-secondary, #6B7280);
  margin: 0;
}

/* Toolbar (launch-in bar, similar to fn-toolbar) */
.v2-ct__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 20px;
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--border, #E5E7EB);
  flex-shrink: 0;
  gap: 12px;
}

.v2-ct__toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-ct__toolbar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #6B7280);
  text-transform: uppercase;
  margin-right: 2px;
}

.v2-ct__toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #374151);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.v2-ct__toolbar-btn i {
  font-size: 11px;
  color: #6366F1;
}

.v2-ct__toolbar-btn:hover:not(:disabled) {
  background: #EEF2FF;
  border-color: #A5B4FC;
  color: #4338CA;
}

.v2-ct__toolbar-btn--disabled,
.v2-ct__toolbar-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Search input */
.v2-ct__search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.v2-ct__search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-secondary, #9CA3AF);
  font-size: 12px;
  pointer-events: none;
}

.v2-ct__search-input {
  padding: 7px 12px 7px 30px;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-primary, #1F2937);
  background: var(--bg-surface, #ffffff);
  width: 230px;
  transition: border-color 0.15s;
}

.v2-ct__search-input:focus {
  outline: none;
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.12);
}

.v2-ct__search-input::placeholder {
  color: var(--text-secondary, #9CA3AF);
}

.v2-ct__search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.v2-ct__search-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary, #1F2937);
  transition: background 0.1s;
}

.v2-ct__search-option:hover {
  background: var(--bg-elev, #F3F4F6);
}

.v2-ct__search-option strong {
  color: var(--accent, #0964A0);
  min-width: 52px;
}

.v2-ct__search-option span {
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Benchmark input */
.v2-ct__bench-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-ct__bench-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #6B7280);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.v2-ct__bench-input {
  padding: 7px 10px;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #1F2937);
  background: var(--bg-surface, #ffffff);
  width: 80px;
  text-transform: uppercase;
  text-align: center;
  transition: border-color 0.15s;
}

.v2-ct__bench-input:focus {
  outline: none;
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.12);
}

.v2-ct__bench-name {
  font-size: 12px;
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Subtitle warning */
.v2-ct__subtitle--warn {
  color: #D97706;
  font-weight: 500;
}

/* Minimum securities warning */
.v2-ct__min-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #FFFBEB;
  border-bottom: 1px solid #FDE68A;
  color: #92400E;
  font-size: 13px;
}

.v2-ct__min-warn i {
  color: #D97706;
}

/* Security Chip Strip */
.v2-ct__strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border, #E5E7EB);
  overflow-x: auto;
  flex-shrink: 0;
}

.v2-ct__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 10px;
  background: var(--bg-elev, #F8FAFC);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 8px;
  border-left: 3px solid var(--chip-color, #0964A0);
  transition: box-shadow 0.15s, border-color 0.15s;
  max-width: 280px;
  flex-shrink: 0;
}

.v2-ct__chip:hover {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  border-color: color-mix(in srgb, var(--chip-color, #0964A0) 40%, var(--border, #E2E8F0));
}

.v2-ct__chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.v2-ct__chip-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.v2-ct__chip-ticker {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #1E293B);
  line-height: 1.2;
}

.v2-ct__chip-name {
  font-size: 11px;
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 200px;
}

.v2-ct__chip-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #9CA3AF);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.15s;
  padding: 0;
  flex-shrink: 0;
  margin-left: auto;
}

.v2-ct__chip-remove:hover {
  background: #FEE2E2;
  color: #DC2626;
}

/* Empty state */
.v2-ct__empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.v2-ct__empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elev, #F3F4F6);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.v2-ct__empty-icon i {
  font-size: 20px;
  color: var(--text-secondary, #9CA3AF);
}

.v2-ct__empty-state h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1F2937);
  margin: 0 0 4px 0;
}

.v2-ct__empty-state p {
  font-size: 12px;
  color: var(--text-secondary, #6B7280);
  margin: 0;
  max-width: 400px;
}

/* Comparison tables */
.v2-ct__table-wrap {
  overflow-x: auto;
  padding: 0 !important;
  min-height: auto !important;
}

.v2-ct__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.v2-ct__table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elev, #F9FAFB);
  border-bottom: 2px solid var(--border, #E5E7EB);
  padding: 10px 14px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.v2-ct__table-metric {
  text-align: left !important;
  min-width: 120px;
}

.v2-ct__table-ticker {
  font-weight: 700 !important;
  letter-spacing: 0.3px;
}

.v2-ct__table tbody tr {
  border-bottom: 1px solid var(--border, #F3F4F6);
  transition: background 0.1s;
}

.v2-ct__table tbody tr:hover {
  background: var(--bg-elev, #F9FAFB);
}

.v2-ct__table tbody td {
  padding: 9px 14px;
  text-align: right;
  white-space: nowrap;
  color: var(--text-primary, #1F2937);
}

.v2-ct__table-label {
  text-align: left !important;
  font-weight: 500;
  color: var(--text-secondary, #4B5563) !important;
}

.v2-ct__table td.positive { color: #059669; font-weight: 500; }
.v2-ct__table td.negative { color: #DC2626; font-weight: 500; }

.v2-ct__best {
  background: rgba(5, 150, 105, 0.06) !important;
  font-weight: 600 !important;
  color: #059669 !important;
}

.v2-ct__table--compact {
  font-size: 12px;
}

.v2-ct__table--compact th,
.v2-ct__table--compact td {
  padding: 7px 10px;
}

.text-right { text-align: right !important; }

/* Content area - inherits v2-sp tab/content styles */
.v2-ct__content {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* AG Grid: auto row height with max (scroll inside) */
.v2-ct__grid-scroll {
  width: 100%;
  overflow: auto;
}

.v2-ct__grid-scroll--risk {
  max-height: 320px;
}

.v2-ct__grid-scroll--fund {
  max-height: 480px;
}

.v2-ct__grid-scroll--fund-trans {
  max-height: 420px;
  min-height: 120px;
}

/* Dark theme overrides */
.dark-theme .v2-ct__header,
[data-theme="dark"] .v2-ct__header {
  background: var(--bg-surface, #111827);
  border-color: var(--border, #374151);
}
.dark-theme .v2-ct__title { color: #F9FAFB; }
.dark-theme .v2-ct__title i { color: var(--accent, #0964A0); }
.dark-theme .v2-ct__subtitle { color: #9CA3AF; }
.dark-theme .v2-ct__strip,
[data-theme="dark"] .v2-ct__strip {
  background: var(--bg-surface, #111827);
  border-color: var(--border, #374151);
}
.dark-theme .v2-ct__chip,
[data-theme="dark"] .v2-ct__chip {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  border-left-color: var(--chip-color, #0964A0);
}

.dark-theme .v2-ct__chip-ticker,
[data-theme="dark"] .v2-ct__chip-ticker {
  color: #E5E7EB;
}

.dark-theme .v2-ct__search-input,
.dark-theme .v2-ct__bench-input,
[data-theme="dark"] .v2-ct__search-input,
[data-theme="dark"] .v2-ct__bench-input {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  color: var(--text-primary, #F9FAFB);
}

.dark-theme .v2-ct__min-warn,
[data-theme="dark"] .v2-ct__min-warn {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.3);
  color: #FCD34D;
}

.dark-theme .v2-ct__min-warn i,
[data-theme="dark"] .v2-ct__min-warn i {
  color: #FBBF24;
}

.dark-theme .v2-ct__search-dropdown,
[data-theme="dark"] .v2-ct__search-dropdown {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
}

.dark-theme .v2-ct__search-option:hover,
[data-theme="dark"] .v2-ct__search-option:hover {
  background: var(--bg-surface, #111827);
}

.dark-theme .v2-ct__table thead th,
[data-theme="dark"] .v2-ct__table thead th {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
}

.dark-theme .v2-ct__table tbody tr,
[data-theme="dark"] .v2-ct__table tbody tr {
  border-color: var(--border, #374151);
}

.dark-theme .v2-ct__table tbody tr:hover,
[data-theme="dark"] .v2-ct__table tbody tr:hover {
  background: var(--bg-elev, #1F2937);
}

.dark-theme .v2-ct__empty-icon,
[data-theme="dark"] .v2-ct__empty-icon {
  background: var(--bg-surface, #111827);
}

/* Error / empty / placeholder messages */
.v2-ct__error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary, #6B7280);
  font-size: 13px;
}

.v2-ct__empty-msg {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary, #6B7280);
  font-size: 13px;
}

.v2-ct__tab-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary, #9CA3AF);
  font-size: 14px;
}

.v2-ct__tab-placeholder p {
  margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .v2-ct__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .v2-ct__header-right {
    width: 100%;
  }

  .v2-ct__search-input {
    width: 100%;
  }

  .v2-ct__strip {
    padding: 8px 12px;
    gap: 6px;
  }

  .v2-ct__chip-name {
    max-width: 120px;
  }

  .v2-ct__content {
    padding: 12px;
  }
}

/* ======================================================================
   RUN COMPARISON BUTTON
   ====================================================================== */

.v2-ct__run-btn {
  background: var(--accent, #0964A0);
  color: #fff;
  border: 1px solid var(--accent, #0964A0);
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.v2-ct__run-btn:hover:not(.disabled) {
  background: var(--accent-hover, #07537e);
  border-color: var(--accent-hover, #07537e);
}

.v2-ct__run-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.v2-ct__run-btn--pulse {
  animation: ct-run-pulse 1.8s ease-in-out infinite;
}

@keyframes ct-run-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(9, 100, 160, 0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(9, 100, 160, 0); }
}

/* ======================================================================
   RUN PROMPT (in tab placeholder)
   ====================================================================== */

.v2-ct__run-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.v2-ct__run-prompt-icon {
  font-size: 36px;
  color: var(--accent, #0964A0);
  opacity: 0.5;
}

.v2-ct__run-prompt p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary, #6B7280);
}

/* ======================================================================
   TEMPLATE SELECT (header)
   ====================================================================== */

.v2-ct__tmpl-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.v2-ct__tmpl-select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  background: var(--bg, #fff);
  color: var(--text-primary, #111827);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 160px;
}

.dark-theme .v2-ct__tmpl-select,
[data-theme="dark"] .v2-ct__tmpl-select {
  background-color: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  color: var(--text-primary, #F9FAFB);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239CA3AF'/%3E%3C/svg%3E");
}

/* ======================================================================
   TEMPLATE PANEL (overlay)
   ====================================================================== */

.v2-ct__content-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.v2-ct__tmpl-panel {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #E2E8F0);
  overflow: hidden;
}

.dark-theme .v2-ct__tmpl-panel,
[data-theme="dark"] .v2-ct__tmpl-panel {
  background: var(--bg-surface, #111827);
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #E2E8F0);
  background: var(--bg-elev, #F9FAFB);
  flex-shrink: 0;
}

.dark-theme .v2-ct__tmpl-panel-header,
[data-theme="dark"] .v2-ct__tmpl-panel-header {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary, #111827);
}

.dark-theme .v2-ct__tmpl-panel-header h2,
[data-theme="dark"] .v2-ct__tmpl-panel-header h2 {
  color: var(--text-primary, #F9FAFB);
}

.v2-ct__tmpl-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary, #6B7280);
  padding: 4px 8px;
  border-radius: 4px;
}

.v2-ct__tmpl-panel-close:hover {
  background: var(--bg-elev, #F3F4F6);
  color: var(--text-primary, #111827);
}

.v2-ct__tmpl-panel-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.v2-ct__tmpl-panel-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border, #E2E8F0);
  background: var(--bg-elev, #F9FAFB);
  flex-shrink: 0;
}

.dark-theme .v2-ct__tmpl-panel-footer,
[data-theme="dark"] .v2-ct__tmpl-panel-footer {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
}

/* --- Sidebar (saved templates) --- */

.v2-ct__tmpl-sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--border, #E2E8F0);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dark-theme .v2-ct__tmpl-sidebar,
[data-theme="dark"] .v2-ct__tmpl-sidebar {
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-sidebar-title {
  margin: 0;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #6B7280);
  border-bottom: 1px solid var(--border, #E2E8F0);
}

.dark-theme .v2-ct__tmpl-sidebar-title,
[data-theme="dark"] .v2-ct__tmpl-sidebar-title {
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.v2-ct__tmpl-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border, #F3F4F6);
  color: var(--text-primary, #111827);
  transition: background 0.15s;
}

.v2-ct__tmpl-list-item:hover {
  background: var(--bg-elev, #F3F4F6);
}

.v2-ct__tmpl-list-item.is-active {
  background: rgba(9, 100, 160, 0.08);
  font-weight: 600;
  color: var(--accent, #0964A0);
}

.dark-theme .v2-ct__tmpl-list-item,
[data-theme="dark"] .v2-ct__tmpl-list-item {
  color: var(--text-primary, #E5E7EB);
  border-color: var(--border, #374151);
}

.dark-theme .v2-ct__tmpl-list-item:hover,
[data-theme="dark"] .v2-ct__tmpl-list-item:hover {
  background: var(--bg-elev, #1F2937);
}

.dark-theme .v2-ct__tmpl-list-item.is-active,
[data-theme="dark"] .v2-ct__tmpl-list-item.is-active {
  background: rgba(9, 100, 160, 0.2);
}

.v2-ct__tmpl-delete {
  background: none;
  border: none;
  color: var(--text-secondary, #9CA3AF);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}

.v2-ct__tmpl-list-item:hover .v2-ct__tmpl-delete {
  opacity: 1;
}

.v2-ct__tmpl-delete:hover {
  color: #DC2626;
}

.v2-ct__tmpl-sidebar-actions {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border, #E2E8F0);
}

.dark-theme .v2-ct__tmpl-sidebar-actions,
[data-theme="dark"] .v2-ct__tmpl-sidebar-actions {
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-name-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  background: var(--bg, #fff);
  color: var(--text-primary, #111827);
  font-size: 12px;
}

.v2-ct__tmpl-name-input:focus {
  outline: none;
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.15);
}

.v2-ct__tmpl-name-input--error {
  border-color: #DC2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.dark-theme .v2-ct__tmpl-name-input,
[data-theme="dark"] .v2-ct__tmpl-name-input {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  color: var(--text-primary, #F9FAFB);
}

/* --- Picker (center: grouped checkboxes) --- */

.v2-ct__tmpl-picker {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border, #E2E8F0);
}

.dark-theme .v2-ct__tmpl-picker,
[data-theme="dark"] .v2-ct__tmpl-picker {
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #E2E8F0);
}

.dark-theme .v2-ct__tmpl-picker-header,
[data-theme="dark"] .v2-ct__tmpl-picker-header {
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-picker-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

.dark-theme .v2-ct__tmpl-picker-header h3,
[data-theme="dark"] .v2-ct__tmpl-picker-header h3 {
  color: var(--text-primary, #E5E7EB);
}

.v2-ct__tmpl-picker-actions {
  display: flex;
  gap: 6px;
}

.v2-ct__tmpl-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.v2-ct__tmpl-group {
  margin-bottom: 4px;
}

.v2-ct__tmpl-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary, #111827);
  background: var(--bg-elev, #F9FAFB);
  border-bottom: 1px solid var(--border, #F3F4F6);
}

.dark-theme .v2-ct__tmpl-group-header,
[data-theme="dark"] .v2-ct__tmpl-group-header {
  background: var(--bg-elev, #1F2937);
  color: var(--text-primary, #E5E7EB);
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-group-count {
  font-weight: 400;
  color: var(--text-secondary, #9CA3AF);
  font-size: 11px;
}

.v2-ct__tmpl-group-fields {
  padding: 4px 14px 4px 34px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-ct__tmpl-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 0;
  cursor: pointer;
  color: var(--text-primary, #374151);
}

.dark-theme .v2-ct__tmpl-field-label,
[data-theme="dark"] .v2-ct__tmpl-field-label {
  color: var(--text-primary, #D1D5DB);
}

.v2-ct__tmpl-field-label:hover {
  color: var(--accent, #0964A0);
}

.v2-ct__tmpl-field-label input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}

/* --- Selected fields (right column) --- */

.v2-ct__tmpl-selected {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.v2-ct__tmpl-selected h3 {
  margin: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  border-bottom: 1px solid var(--border, #E2E8F0);
}

.dark-theme .v2-ct__tmpl-selected h3,
[data-theme="dark"] .v2-ct__tmpl-selected h3 {
  color: var(--text-primary, #E5E7EB);
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-sel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.v2-ct__tmpl-sel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-primary, #374151);
  border-bottom: 1px solid var(--border, #F3F4F6);
}

.dark-theme .v2-ct__tmpl-sel-item,
[data-theme="dark"] .v2-ct__tmpl-sel-item {
  color: var(--text-primary, #D1D5DB);
  border-color: var(--border, #374151);
}

.v2-ct__tmpl-sel-remove {
  background: none;
  border: none;
  color: var(--text-secondary, #9CA3AF);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0.5;
}

.v2-ct__tmpl-sel-remove:hover {
  opacity: 1;
  color: #DC2626;
}

/* =========================================================================
 * Tab bar (Overview / Performance / Risk / Composition / Fundamentals / Holdings)
 * ========================================================================= */
.v2-ct__tabs {
  padding: 0 20px;
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--border, #E5E7EB);
  flex-shrink: 0;
}

.dark-theme .v2-ct__tabs,
[data-theme="dark"] .v2-ct__tabs {
  background: var(--bg-surface, #111827);
  border-color: var(--border, #374151);
}

.dark-theme .v2-ct__tabs .v2-sp__tab { color: #8b92a5; }
.dark-theme .v2-ct__tabs .v2-sp__tab:hover { color: #e6e9f0; background: rgba(255, 255, 255, 0.04); }
.dark-theme .v2-ct__tabs .v2-sp__tab.is-active { color: #2BA8E8; border-bottom-color: #2BA8E8; }

.v2-ct__card-sub {
  display: block;
  font-size: 11px;
  color: var(--text-secondary, #6B7280);
  margin-top: 2px;
}

/* Embedded Quick Compare modules — they lay out with their own qc-* classes;
 * neutralise the section chrome so they sit on the page like our cards. */
.v2-ct__qc-host .qc-section,
.v2-ct__qc-host .qc-comp-card {
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.v2-ct__qc-host .qc-chart { height: 400px; }

/* =========================================================================
 * Holdings tab
 * ========================================================================= */
.v2-ct__hold-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.v2-ct__hold-card {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-top: 3px solid var(--chip-color, #0964A0);
  border-radius: 8px;
  padding: 10px 14px 8px;
  min-width: 0;
}

.v2-ct__hold-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.v2-ct__hold-card-ticker {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #111827);
}

.v2-ct__hold-card-type {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary, #6B7280);
  background: var(--bg-elev, #F3F4F6);
  border-radius: 4px;
  padding: 2px 6px;
}

.v2-ct__hold-card-name {
  font-size: 11px;
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 8px;
}

.v2-ct__hold-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.v2-ct__hold-kpis > div { display: flex; flex-direction: column; min-width: 0; }

.v2-ct__hold-kpi-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  font-variant-numeric: tabular-nums;
}

.v2-ct__hold-kpi-lbl {
  font-size: 10px;
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
}

.v2-ct__hold-card-foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border, #E5E7EB);
  font-size: 10.5px;
  color: var(--text-secondary, #9CA3AF);
}

/* Two-fund overlap hero */
.v2-ct__hold-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 300px;
  padding: 12px;
}

.v2-ct__hold-hero-val {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent, #0964A0);
  font-variant-numeric: tabular-nums;
}

.v2-ct__hold-hero-lbl {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-primary, #374151);
}

.v2-ct__hold-hero-bar {
  width: 70%;
  height: 10px;
  margin: 16px 0 10px;
  background: var(--bg-elev, #F3F4F6);
  border-radius: 999px;
  overflow: hidden;
}

.v2-ct__hold-hero-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0964A0, #2BA8E8);
  border-radius: 999px;
}

.v2-ct__hold-hero-sub {
  font-size: 11.5px;
  color: var(--text-secondary, #6B7280);
}

/* N-fund overlap matrix */
.v2-ct__hold-matrix-wrap { overflow: auto; }

.v2-ct__hold-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.v2-ct__hold-matrix th {
  font-weight: 600;
  color: var(--text-primary, #374151);
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
}

.v2-ct__hold-matrix tbody th { text-align: left; }

.v2-ct__hold-matrix th .v2-ct__chip-dot {
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
}

.v2-ct__hold-matrix td {
  text-align: center;
  padding: 10px 6px;
  border-radius: 4px;
  color: var(--text-primary, #111827);
  font-weight: 500;
}

.v2-ct__hold-matrix td.is-self {
  color: var(--text-secondary, #9CA3AF);
  background: var(--bg-elev, #F3F4F6);
}

/* Holdings card header controls */
.v2-ct__hold-head { flex-wrap: wrap; gap: 8px; }

.v2-ct__hold-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.v2-ct__hold-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.v2-ct__hold-search i {
  position: absolute;
  left: 8px;
  font-size: 11px;
  color: var(--text-secondary, #9CA3AF);
  pointer-events: none;
}

.v2-ct__hold-search input {
  height: 28px;
  width: 190px;
  padding: 0 8px 0 26px;
  font-size: 12px;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
}

.v2-ct__hold-search input:focus {
  outline: none;
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.15);
}

/* Side-by-side columns */
.v2-ct__hold-grid {
  display: grid;
  grid-template-columns: repeat(var(--hold-cols, 2), minmax(240px, 1fr));
  gap: 0;
  overflow-x: auto;
}

.v2-ct__hold-col {
  min-width: 0;
  border-right: 1px solid var(--border, #E5E7EB);
  display: flex;
  flex-direction: column;
}

.v2-ct__hold-col:last-child { border-right: none; }

.v2-ct__hold-col-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border-top: 3px solid transparent;
  border-bottom: 1px solid var(--border, #E5E7EB);
  background: var(--bg-elev, #F9FAFB);
  position: sticky;
  top: 0;
  z-index: 1;
}

.v2-ct__hold-col-tk {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #111827);
}

.v2-ct__hold-col-n {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary, #6B7280);
}

.v2-ct__hold-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.v2-ct__hold-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 110px 30px;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border, #F3F4F6);
  font-size: 12px;
  transition: background 0.1s ease;
}

.v2-ct__hold-row.is-hl { background: rgba(9, 100, 160, 0.08); }

.v2-ct__hold-rank {
  font-size: 10.5px;
  color: var(--text-secondary, #9CA3AF);
  font-variant-numeric: tabular-nums;
}

.v2-ct__hold-id { display: flex; flex-direction: column; min-width: 0; }

.v2-ct__hold-tk {
  font-weight: 600;
  color: var(--text-primary, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-ct__hold-nm {
  font-size: 10.5px;
  color: var(--text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-ct__hold-wt { display: flex; align-items: center; gap: 6px; }

.v2-ct__hold-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elev, #F3F4F6);
  border-radius: 3px;
  overflow: hidden;
}

.v2-ct__hold-bar span { display: block; height: 100%; border-radius: 3px; }

.v2-ct__hold-wt-val {
  width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary, #111827);
}

.v2-ct__hold-dots { display: flex; gap: 2px; justify-content: flex-end; }

.v2-ct__hold-dots i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.v2-ct__hold-more {
  margin: 8px 12px 10px;
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border, #D1D5DB);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--accent, #0964A0);
  cursor: pointer;
}

.v2-ct__hold-more:hover { background: var(--bg-elev, #F3F4F6); }

.v2-ct__hold-legend {
  padding: 8px 14px;
  border-top: 1px solid var(--border, #E5E7EB);
  font-size: 11px;
  color: var(--text-secondary, #6B7280);
}

.v2-ct__hold-legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #0964A0);
  margin-right: 4px;
}

/* Holdings tab — dark theme */
.dark-theme .v2-ct__hold-card,
[data-theme="dark"] .v2-ct__hold-card {
  background: var(--bg-surface, #111827);
  border-color: var(--border, #374151);
  border-top-color: var(--chip-color, #0964A0);
}

.dark-theme .v2-ct__hold-card-ticker,
.dark-theme .v2-ct__hold-kpi-val,
.dark-theme .v2-ct__hold-col-tk,
.dark-theme .v2-ct__hold-tk,
.dark-theme .v2-ct__hold-wt-val,
.dark-theme .v2-ct__hold-matrix td,
.dark-theme .v2-ct__hold-matrix th,
.dark-theme .v2-ct__hold-hero-lbl { color: #E5E7EB; }

.dark-theme .v2-ct__hold-card-type,
.dark-theme .v2-ct__hold-col-head,
.dark-theme .v2-ct__hold-bar,
.dark-theme .v2-ct__hold-hero-bar,
.dark-theme .v2-ct__hold-matrix td.is-self {
  background: var(--bg-elev, #1F2937);
}

.dark-theme .v2-ct__hold-col,
.dark-theme .v2-ct__hold-col-head,
.dark-theme .v2-ct__hold-row,
.dark-theme .v2-ct__hold-legend,
.dark-theme .v2-ct__hold-card-foot { border-color: var(--border, #374151); }

.dark-theme .v2-ct__hold-row.is-hl { background: rgba(43, 168, 232, 0.12); }

.dark-theme .v2-ct__hold-search input,
[data-theme="dark"] .v2-ct__hold-search input {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  color: #F9FAFB;
}

.dark-theme .v2-ct__hold-more { border-color: var(--border, #374151); color: #2BA8E8; }
.dark-theme .v2-ct__hold-more:hover { background: var(--bg-elev, #1F2937); }
.dark-theme .v2-ct__hold-hero-val { color: #2BA8E8; }

@media (max-width: 1100px) {
  .v2-ct__hold-charts { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Fees + Distributions tabs — field-by-fund comparison table
   (summary cards and chart grid reuse the Holdings tab classes above)
   --------------------------------------------------------------------------- */
.v2-ct__fee-table-wrap { overflow-x: auto; }

.v2-ct__fee-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.v2-ct__fee-table thead th {
  text-align: right;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary, #111827);
  background: var(--bg-elev, #F3F4F6);
  border-bottom: 1px solid var(--border, #E5E7EB);
  white-space: nowrap;
}
.v2-ct__fee-table thead th small { font-weight: 500; color: var(--text-secondary, #6B7280); margin-left: 4px; }
.v2-ct__fee-table thead th.v2-ct__fee-th-label { text-align: left; min-width: 200px; }

.v2-ct__fee-table tbody td {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border, #E5E7EB);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary, #111827);
  white-space: nowrap;
}
.v2-ct__fee-table tbody td.v2-ct__fee-label {
  text-align: left;
  color: var(--text-secondary, #4B5563);
  font-weight: 500;
}
.v2-ct__fee-table tbody tr:hover td { background: var(--bg-elev, #F9FAFB); }
.v2-ct__fee-table tbody td.is-best {
  color: #059669;
  font-weight: 600;
  background: rgba(5, 150, 105, 0.06);
}

.v2-ct__fee-note {
  margin: 0;
  padding: 10px 14px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary, #6B7280);
}

.dark-theme .v2-ct__fee-table thead th,
[data-theme="dark"] .v2-ct__fee-table thead th {
  background: var(--bg-elev, #1F2937);
  border-color: var(--border, #374151);
  color: #E5E7EB;
}
.dark-theme .v2-ct__fee-table tbody td { border-color: var(--border, #374151); color: #E5E7EB; }
.dark-theme .v2-ct__fee-table tbody td.v2-ct__fee-label { color: #9CA3AF; }
.dark-theme .v2-ct__fee-table tbody tr:hover td { background: var(--bg-elev, #1F2937); }
.dark-theme .v2-ct__fee-table tbody td.is-best { color: #34D399; background: rgba(52, 211, 153, 0.1); }

/* ======================================================================
   COMPARE REPORT CHOOSER (new report engine vs classic PDF)
   ====================================================================== */

.v2-ct__chooser-overlay {
  position: fixed; inset: 0; z-index: 10050;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.v2-ct__chooser {
  width: 100%; max-width: 560px;
  background: var(--bg, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25); overflow: hidden;
}
.v2-ct__chooser-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border, #E2E8F0);
}
.v2-ct__chooser-title { font-size: 15px; font-weight: 600; color: var(--text-primary, #111827); }
.v2-ct__chooser-sub { font-size: 12px; color: var(--text-secondary, #6B7280); margin-top: 2px; }
.v2-ct__chooser-close { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--text-secondary, #6B7280); }
.v2-ct__chooser-opts { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }
.v2-ct__chooser-opt {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  padding: 12px 14px; border: 1px solid var(--border, #E2E8F0); border-radius: 8px;
  background: var(--bg, #fff); cursor: pointer; transition: border-color .15s, background .15s;
}
.v2-ct__chooser-opt:hover { border-color: var(--accent, #0964A0); background: rgba(9,100,160,0.04); }
.v2-ct__chooser-opt.is-primary { border-color: rgba(9,100,160,0.45); }
.v2-ct__chooser-ico {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: rgba(9,100,160,0.10); color: var(--accent, #0964A0);
}
.v2-ct__chooser-body { display: block; min-width: 0; }
.v2-ct__chooser-body b { font-size: 13.5px; color: var(--text-primary, #111827); }
.v2-ct__chooser-body small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.45; color: var(--text-secondary, #6B7280); }
.v2-ct__chooser-tag {
  display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 10px; vertical-align: 1px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--accent, #0964A0); color: #fff;
}
.dark-theme .v2-ct__chooser, [data-theme="dark"] .v2-ct__chooser { background: var(--bg-surface, #111827); border-color: var(--border, #374151); }
.dark-theme .v2-ct__chooser-head, [data-theme="dark"] .v2-ct__chooser-head { border-color: var(--border, #374151); }
.dark-theme .v2-ct__chooser-title, .dark-theme .v2-ct__chooser-body b { color: #F9FAFB; }
.dark-theme .v2-ct__chooser-opt { background: var(--bg-elev, #1F2937); border-color: var(--border, #374151); }
.dark-theme .v2-ct__chooser-opt:hover { background: #243041; }
.dark-theme .v2-ct__chooser-ico { background: rgba(96,165,250,0.15); color: #93c5fd; }
