/* Global Design System & Variables */
:root {
  --bg-app: #07090e;
  --bg-card: rgba(13, 17, 28, 0.7);
  --border-card: rgba(255, 255, 255, 0.06);
  --border-card-focus: rgba(111, 66, 251, 0.4);
  
  /* Palette */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #00f2fe;
  --accent-purple: #7f00ff;
  --accent-indigo: #6366f1;
  --accent-gradient: linear-gradient(135deg, #7f00ff 0%, #00f2fe 100%);
  --accent-gradient-hover: linear-gradient(135deg, #8f1fff 0%, #1af4ff 100%);
  
  --color-green: #10b981;
  --color-green-glow: rgba(16, 185, 129, 0.15);
  --color-red: #ef4444;
  --color-red-glow: rgba(239, 68, 68, 0.15);
  --color-orange: #f59e0b;
  --color-orange-glow: rgba(245, 158, 11, 0.15);
  
  /* Shadow & Glows */
  --glow-accent: 0 0 20px rgba(127, 0, 255, 0.25);
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(127, 0, 255, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
  overflow-x: hidden;
}

.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  position: relative;
  gap: 12px;
}

.logo-glow {
  position: absolute;
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  filter: blur(15px);
  opacity: 0.6;
  border-radius: 50%;
  z-index: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-cyan);
  z-index: 1;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
  animation: float 4s ease-in-out infinite;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 2px;
  z-index: 1;
}

.logo-text .highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-tagline {
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.app-header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.header-btn {
  padding: 9px 14px;
}

.header-meta-pill,
.header-date-field {
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
}

.header-meta-pill span,
.header-date-field span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-meta-pill strong {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
}

.name-pill strong {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-date-field input {
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font: 700 13px var(--font-display);
  outline: 0;
  width: 130px;
}

/* Dashboard Summary Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.positions-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .positions-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.tab-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 700px) {
  .tab-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.metric-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}

.metric-title {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.metric-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.trend-icon {
  width: 16px;
  height: 16px;
}

.metric-subtitle {
  color: var(--text-muted);
  font-size: 12px;
}

.text-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Status Badges */
.metric-status-badge {
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 10px;
  margin-bottom: 6px;
}

.green-badge {
  background-color: var(--color-green-glow);
  color: var(--color-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.red-badge {
  background-color: var(--color-red-glow);
  color: var(--color-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.orange-badge {
  background-color: var(--color-orange-glow);
  color: var(--color-orange);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Workspace Layout & Grid Systems */
.top-row-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 28px;
  align-items: stretch;
}

@media (max-width: 1000px) {
  .top-row-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.card {
  padding: 24px;
  margin-bottom: 24px;
}

.chart-card-compact {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.chart-card-compact .chart-container {
  height: 190px;
  margin-top: 8px;
}

/* Workspace Navigation Tabs */
.workspace-tabs-container {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.workspace-tabs-header {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 24px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 12px 24px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.02);
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.tab-btn-icon {
  width: 18px;
  height: 18px;
}

.tab-badge {
  background: var(--accent-indigo);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 4px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeInTab 0.3s ease-out forwards;
}

@keyframes fadeInTab {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sub-tabs in Rebalancing Panel */
.sub-tabs-header {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 14px;
}

.sub-tab-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  color: var(--text-secondary);
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sub-tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.sub-tab-btn.active {
  background: var(--accent-indigo);
  color: #fff;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.card-header {
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* Form Controls & Inputs */
.control-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.portfolio-controls-card {
  margin-bottom: 16px;
}

.portfolio-control-row {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.6fr) minmax(90px, 0.35fr) auto;
}
.portfolio-control-row .control-group:last-child {
  align-self: end;
  padding-bottom: 2px;
}

@media (max-width: 600px) {
  .control-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .portfolio-control-row {
    grid-template-columns: 1fr;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  width: 100%;
  transition: all 0.25s ease;
}

.form-input:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-indigo);
  background: rgba(13, 17, 28, 0.95);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

/* Select Styling */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '▼';
  font-size: 10px;
  color: var(--text-secondary);
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
}

/* Numeric input prefix */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}

.numeric-input {
  padding-left: 32px;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  border: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: var(--glow-accent);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-red);
  margin-left: auto; /* Push to the right */
}

.btn-danger-outline:hover {
  background: var(--color-red-glow);
  border-color: var(--color-red);
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* Data Table Card & Floating Rows */
.table-card {
  padding: 0;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 18px;
}

@media (max-width: 768px) {
  .table-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .table-header-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  #table-fund-input-slot .control-group {
    width: 100%;
  }

  #table-fund-input-slot {
    flex-direction: column;
    width: 100%;
  }
}

.master-switch-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px 16px;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.table-header-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-shrink: 0;
}

.holdings-total-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.holdings-total-strip span {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 7px 10px;
}

.holdings-total-strip strong {
  color: var(--text-primary);
  font-family: var(--font-display);
  margin-left: 6px;
}

#table-fund-input-slot .control-group {
  width: 220px;
}

#table-fund-input-slot {
  display: flex;
  gap: 12px;
}

#table-fund-input-slot .field-label {
  white-space: nowrap;
}

.master-switch-container:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.switch-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.switch-label.active {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.4);
}

/* Premium Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: .3s ease;
  border-radius: 22px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s ease;
  border-radius: 50%;
}

.switch-toggle input:checked + .switch-slider {
  background-color: rgba(0, 242, 254, 0.12);
  border-color: var(--accent-cyan);
}

.switch-toggle input:checked + .switch-slider:before {
  transform: translateX(22px);
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
}

.table-container {
  overflow-x: auto;
  max-width: 100%;
  padding: 8px 24px 20px 24px; /* Spacious margins around the table */
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px; /* Separates the rows into cards */
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 10px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  border: none;
}

.data-table tbody tr {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.data-table tbody tr td {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.015);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  border-right: none;
  border-left: none;
  transition: all 0.25s ease;
}

.data-table tbody tr td:first-child {
  border-left: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px 0 0 8px;
}

.data-table tbody tr td:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 0 8px 8px 0;
}

/* Distinct holding row color bands */
.data-table tbody tr:nth-child(6n + 1) td {
  background: rgba(0, 242, 254, 0.055);
  border-color: rgba(0, 242, 254, 0.11);
}

.data-table tbody tr:nth-child(6n + 2) td {
  background: rgba(16, 185, 129, 0.052);
  border-color: rgba(16, 185, 129, 0.105);
}

.data-table tbody tr:nth-child(6n + 3) td {
  background: rgba(245, 158, 11, 0.055);
  border-color: rgba(245, 158, 11, 0.11);
}

.data-table tbody tr:nth-child(6n + 4) td {
  background: rgba(99, 102, 241, 0.058);
  border-color: rgba(99, 102, 241, 0.12);
}

.data-table tbody tr:nth-child(6n + 5) td {
  background: rgba(236, 72, 153, 0.052);
  border-color: rgba(236, 72, 153, 0.105);
}

.data-table tbody tr:nth-child(6n) td {
  background: rgba(148, 163, 184, 0.052);
  border-color: rgba(148, 163, 184, 0.105);
}

/* Row states & hover highlights */
.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.08);
}

.data-table tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.data-table tbody tr.row-editing-active td {
  background: rgba(99, 102, 241, 0.03);
  border-color: rgba(99, 102, 241, 0.12);
}

.data-table tbody tr.row-editing-active:hover td {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.24);
}

/* Static Display Text Inside Table */
.cell-text-display {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
}

.cell-text-display.text-bold {
  font-weight: 600;
}

.cell-text-display.text-muted-val {
  color: var(--text-secondary);
}

.cell-text-display.text-accent {
  color: var(--accent-cyan);
  font-weight: 600;
}

.cell-text-display.font-medium {
  font-weight: 500;
}

.cell-text-display.font-semibold {
  font-weight: 600;
}

.num-col {
  text-align: right;
}

.action-col {
  text-align: center;
  width: 60px;
}

.table-cell-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  width: 100%;
  transition: all 0.2s ease;
}

.table-cell-input:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.table-cell-input:focus {
  outline: none;
  background: rgba(8, 11, 17, 0.95);
  border-color: var(--accent-indigo);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.table-cell-input.num-input {
  text-align: right;
  font-weight: 500;
}

.table-cell-input.text-bold {
  font-weight: 600;
}

/* Calculated read-only values */
.calc-value {
  color: var(--text-primary);
  font-weight: 500;
  padding: 6px 10px;
  display: block;
}

.text-muted-val {
  color: var(--text-secondary);
  font-weight: 400;
}

.text-green {
  color: var(--color-green);
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.text-red {
  color: var(--color-red);
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.text-orange {
  color: var(--color-orange);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

/* Delete Button */
.btn-delete-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete-row:hover {
  color: var(--color-red);
  background: var(--color-red-glow);
}

.btn-delete-row-icon {
  width: 16px;
  height: 16px;
}

/* Totals Row */
.total-row {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
  color: var(--text-primary);
}

.total-row td {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  font-size: 13px;
  font-family: var(--font-display);
}

/* Warnings/Info Bar in Table Footer */
.table-info-bar {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.01);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  min-height: 45px;
  display: flex;
  align-items: center;
}

.warning-text {
  color: var(--color-orange);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.warning-text svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Right Column Panel specifics */
.chart-card {
  min-height: 380px;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
  margin-top: 10px;
}

.chart-legend-custom {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 24px;
  margin-top: 16px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: #e2e8f0;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rebalance-card {
  display: flex;
  flex-direction: column;
}

.rebalance-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Drift Index Visualizer */
.drift-progress-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drift-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.drift-progress-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.drift-progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.1, 0.8, 0.25, 1);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

/* Action Recommendation List */
.rebalance-instructions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rebalance-instruction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 4px solid var(--accent-indigo);
  border-radius: 0 8px 8px 0;
  transition: background-color 0.2s ease;
}

.rebalance-instruction-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.rebalance-instruction-item.buy {
  border-left-color: var(--color-green);
}

.rebalance-instruction-item.sell {
  border-left-color: var(--color-red);
}

.rebalance-instruction-item.hold {
  border-left-color: var(--text-muted);
}

.action-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.action-label-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.action-label-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.action-amount-pill {
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.rebalance-meta-fields {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(220px, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.rebalance-meta-fields label {
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  font-size: 10px;
  font-weight: 700;
  gap: 4px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.rebalance-meta-input {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  min-height: 34px;
  padding: 7px 9px;
}

.rebalance-meta-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.25);
  outline: none;
}

.screenshot-card {
  padding: 0;
  overflow: hidden;
}

.screenshot-summary-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 0;
  padding: 20px 24px;
}

.screenshot-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.screenshot-totals span {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 8px 10px;
}

.screenshot-totals strong {
  color: var(--text-primary);
  font-family: var(--font-display);
  margin-left: 6px;
}

.screenshot-table-wrap {
  overflow-x: auto;
  padding: 0 24px 24px;
}

.screenshot-table {
  border-collapse: collapse;
  color: var(--text-primary);
  font-size: 12px;
  min-width: 980px;
  width: 100%;
}

.screenshot-table th,
.screenshot-table td {
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 7px 8px;
}

.screenshot-table thead th {
  background: rgba(15, 23, 42, 0.98);
  color: var(--text-primary);
  font-weight: 600;
}

.screenshot-table tbody td {
  background: rgba(15, 23, 42, 0.92);
}

.screenshot-table tbody tr:nth-child(even) td {
  background: rgba(30, 41, 59, 0.92);
}

.screenshot-table tfoot td {
  background: rgba(8, 47, 73, 0.95);
  color: var(--text-primary);
  font-weight: 700;
}

.manual-trade-toolbar {
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 24px;
}

.toolbar-booked-pnl {
  align-items: end;
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(150px, 180px);
}

.compact-booked-input {
  min-height: 38px;
  padding-bottom: 9px;
  padding-top: 9px;
}

.manual-trade-input {
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font: inherit;
  min-width: 90px;
  outline: none;
  padding: 0;
  width: 100%;
}

.manual-trade-input:focus {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px var(--accent-cyan);
}

.manual-trade-input.num-input {
  text-align: right;
}

.screenshot-table .negative-cell {
  color: var(--color-red);
  font-weight: 700;
}

.screenshot-table .positive-cell {
  color: var(--color-green);
  font-weight: 700;
}

.screenshot-action {
  font-weight: 700;
}

.screenshot-action.hold {
  color: var(--color-orange);
}

.screenshot-action.buy {
  color: var(--color-green);
}

.screenshot-action.sell {
  color: var(--color-red);
}

.section-title-small {
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.option-block + .option-block {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 800px) {
  .rebalance-instruction-item,
  .screenshot-summary-header {
    align-items: stretch;
    flex-direction: column;
  }

  .rebalance-meta-fields {
    grid-template-columns: 1fr;
  }

  .screenshot-totals {
    justify-content: flex-start;
  }
}

.action-amount-pill.buy {
  background-color: var(--color-green-glow);
  color: var(--color-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.action-amount-pill.sell {
  background-color: var(--color-red-glow);
  color: var(--color-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.action-amount-pill.hold {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.no-actions-card {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.05);
}

/* Float Animation */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
  100% { transform: translateY(0px); }
}

/* Animations for new rows */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.new-row-animation {
  animation: slideIn 0.35s ease-out forwards;
}

/* Holdings sub-row and action button group */
.action-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-lens-row {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}
.btn-lens-row:hover {
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.1);
}
.holdings-sub-row td {
  padding: 12px 16px !important;
  background: rgba(255, 255, 255, 0.02);
  border-top: none;
}
.holdings-inner-wrap {
  padding: 4px 0;
}
.holdings-table {
  margin-bottom: 0;
}
.holdings-table th {
  font-size: 11px;
  white-space: nowrap;
}
.holdings-table .manual-trade-input {
  font-size: 12px;
  padding: 3px 6px;
}
.holdings-table input[type="number"] {
  width: 70px;
}
.holdings-table .screenshot-action {
  font-size: 11px;
  padding: 2px 4px;
}

.app-footer {
  text-align: center;
  padding: 20px 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-body);
  letter-spacing: 0.3px;
}
