/* ============================================================
   Calm Dashboard — Investor Dashboard Dark Theme
   Design: 001 Calm Dashboard
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0b0d10;
  --bg-surface: #13161a;
  --bg-surface-hover: #1a1e24;
  --bg-card: #15191e;
  --bg-elevated: #1c2128;
  --border-subtle: #1e232b;
  --border-muted: #2a2f38;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a8;
  --text-muted: #6b7280;
  --text-faint: #484f58;
  --accent-blue: #4b8bff;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #eab308;
  --accent-purple: #a855f7;
  --sidebar-width: 240px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo span {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(75, 139, 255, 0.1);
  color: var(--accent-blue);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-profile {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 0;
}

.main-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.header-left h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.header-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-refresh:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-muted);
}

.btn-refresh:active {
  transform: scale(0.97);
}

.btn-refresh svg {
  transition: transform var(--transition-normal);
}

.btn-refresh.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Stats Row --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  border-color: var(--border-muted);
  background: var(--bg-surface-hover);
  transform: translateY(-1px);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon.blue {
  background: rgba(75, 139, 255, 0.12);
}

.stat-card-icon.green {
  background: rgba(34, 197, 94, 0.12);
}

.stat-card-icon.purple {
  background: rgba(168, 85, 247, 0.12);
}

.stat-card-icon.yellow {
  background: rgba(234, 179, 8, 0.12);
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.stat-card-change {
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-card-change.up {
  color: var(--accent-green);
}

.stat-card-change.down {
  color: var(--accent-red);
}

.stat-card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Grid: Watchlist + Analyse --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Hauteur fixe des panneaux du dashboard avec scroll */
.dashboard-grid .panel {
  max-height: 420px;
  display: flex;
  flex-direction: column;
}

.dashboard-grid .panel .panel-header {
  flex-shrink: 0;
}

.dashboard-grid .panel > div:last-child {
  flex: 1;
  overflow-y: auto;
  max-height: 360px; /* 420 - hauteur header */
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

/* --- Watchlist Table --- */
.watchlist-table {
  width: 100%;
  border-collapse: collapse;
}

.watchlist-table th {
  text-align: left;
  padding: 10px 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.15);
}

.watchlist-table td {
  padding: 12px 20px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.watchlist-table tbody tr {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.watchlist-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

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

.ticker-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticker-name {
  font-weight: 600;
  color: var(--text-primary);
}

.ticker-company {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.price-cell {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.change-cell {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.change-cell.up {
  color: var(--accent-green);
}

.change-cell.down {
  color: var(--accent-red);
}

.sentiment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.sentiment-badge.bullish {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
}

.sentiment-badge.neutral {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
}

.sentiment-badge.bearish {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

/* --- Price Animation --- */
.price-up {
  animation: pulseGreen 1.5s ease;
}

.price-down {
  animation: pulseRed 1.5s ease;
}

@keyframes pulseGreen {
  0%, 100% { color: inherit; }
  30% { color: var(--accent-green); transform: scale(1.04); }
  60% { color: var(--accent-green); }
}

@keyframes pulseRed {
  0%, 100% { color: inherit; }
  30% { color: var(--accent-red); transform: scale(1.04); }
  60% { color: var(--accent-red); }
}

/* --- Analyse Panel --- */
.analyse-search {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.analyse-input {
  flex: 1;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.analyse-input::placeholder {
  color: var(--text-muted);
}

.analyse-input:focus {
  border-color: var(--accent-blue);
}

.btn-analyse {
  padding: 8px 18px;
  background: var(--accent-blue);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
}

.btn-analyse:hover {
  background: #3a7bef;
  transform: translateY(-1px);
}

.btn-analyse:active {
  transform: scale(0.97);
}

.btn-analyse:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Analyse Result --- */
.analyse-result {
  padding: 0;
}

.analyse-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.analyse-placeholder svg {
  margin-bottom: 12px;
  opacity: 0.3;
}

.analyse-placeholder p {
  font-size: 0.9rem;
}

.analyse-ticker-title {
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.analyse-ticker-title .reco {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.analyse-ticker-title .reco.buy {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

.analyse-ticker-title .reco.sell {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.analyse-ticker-title .reco.hold {
  background: rgba(234, 179, 8, 0.15);
  color: var(--accent-yellow);
}

.analyse-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.analyse-section:last-child {
  border-bottom: none;
}

.analyse-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.analyse-section-content {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.analyse-section-content ul {
  list-style: none;
  padding: 0;
}

.analyse-section-content li {
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}

.analyse-section-content li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.analyse-section-content li.bullish::before {
  background: var(--accent-green);
}

.analyse-section-content li.bearish::before {
  background: var(--accent-red);
}

/* --- Skeleton Loader --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-surface-hover) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
  width: 100%;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-line.medium {
  width: 80%;
}

.skeleton-block {
  padding: 20px;
}

.skeleton-row {
  height: 44px;
  margin: 0;
  border-radius: 0;
}

/* --- Error state --- */
.analyse-error {
  padding: 20px;
  text-align: center;
  color: var(--accent-red);
  font-size: 0.88rem;
}

.analyse-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* --- Not Found state for ticker --- */
.not-found {
  padding: 20px;
  text-align: center;
  color: var(--accent-yellow);
  font-size: 0.88rem;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .main-inner {
    padding: 16px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card-value {
    font-size: 1.3rem;
  }

  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
  }
}

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

  .watchlist-table th,
  .watchlist-table td {
    padding: 8px 12px;
  }

  .watchlist-table td {
    font-size: 0.8rem;
  }

  .ticker-company {
    display: none;
  }
}

/* --- Mobile Menu Button --- */
.mobile-menu-btn {
  display: none;
}

/* --- Sidebar Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.open {
  display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   Portfolio Styles
   ============================================================ */

.portfolio-view {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Portfolio panel */
.pf-panel {
  margin-top: 0;
}

/* Portfolio table */
.pf-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pf-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.15);
}

/* Alignement des colonnes numériques */
.pf-table th:nth-child(2),
.pf-table th:nth-child(3),
.pf-table th:nth-child(4),
.pf-table th:nth-child(5),
.pf-table th:nth-child(6),
.pf-table th:nth-child(7) {
  text-align: right;
}

.pf-table th:nth-child(8) {
  text-align: center;
}

.pf-table td:nth-child(2),
.pf-table td:nth-child(3),
.pf-table td:nth-child(4),
.pf-table td:nth-child(5),
.pf-table td:nth-child(6),
.pf-table td:nth-child(7) {
  text-align: right;
}

.pf-table td:nth-child(8) {
  text-align: center;
}

.pf-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.pf-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pf-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

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

.pf-table .up { color: var(--accent-green); }
.pf-table .down { color: var(--accent-red); }

/* Footer row */
.pf-footer td {
  font-weight: 600;
  border-top: 2px solid var(--border-muted);
  border-bottom: none !important;
  background: rgba(0,0,0,0.1);
}

/* Ticker cell */
.pf-ticker-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pf-name {
  font-weight: 600;
  color: var(--text-primary);
}

.pf-ticker {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pf-ticker.no-ticker {
  color: var(--text-faint);
  font-style: italic;
}

/* Status badges */
.pf-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}

.pf-badge-live {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-green);
}

.pf-badge-pending {
  background: rgba(234, 179, 8, 0.12);
  color: var(--accent-yellow);
}

.pf-badge-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

.pf-badge-manual {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

/* P&L input for manual positions */
.pf-pnl-input {
  width: 90px;
  padding: 3px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  text-align: right;
}

.pf-pnl-input:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* Remove button */
.pf-remove-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
  line-height: 1;
}

.pf-remove-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* Add/Save buttons */
.pf-add-btn {
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.pf-add-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(75, 139, 255, 0.06);
}

.pf-save-capital-btn {
  margin-top: 12px;
  padding: 8px 20px;
  background: var(--green-btn, #238636);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.pf-save-capital-btn:hover {
  filter: brightness(1.15);
}

/* Capital collapsible */
.pf-collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.pf-collapsible-body.open {
  max-height: 2000px;
}

/* Capital editor */
.pf-capital-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.pf-capital-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pf-capital-field label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pf-capital-field input {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
}

.pf-capital-field input:focus {
  border-color: var(--accent-blue);
  outline: none;
}

.pf-capital-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  margin-top: 12px;
}

.pf-capital-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pf-capital-line .pf-cap-label {
  flex: 2;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
}

.pf-capital-line .pf-cap-amount {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  text-align: right;
}

.pf-capital-line input:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* Chart period buttons */
.pf-period-btn {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.pf-period-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.pf-period-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

/* Quantity cell */
.pf-qty, .pf-invested, .pf-val {
  text-align: right;
}

.pf-pnl, .pf-ret, .pf-day {
  text-align: right;
  font-weight: 500;
}

/* ============================================================
   Progress Area  (refresh en direct)
   ============================================================ */

.pf-progress-area {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(75, 139, 255, 0.04);
}

.pf-progress-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pf-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.pf-progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: var(--text-muted);
  animation: fadeIn 0.15s ease;
}

.pf-progress-step .pf-step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pf-progress-step.done {
  color: var(--text-secondary);
}

.pf-progress-step.done .pf-step-dot {
  background: var(--accent-green);
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.pf-progress-step.error .pf-step-dot {
  background: var(--accent-red);
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

.pf-progress-step.pending .pf-step-dot {
  background: var(--text-faint);
  animation: pf-pulse 1s infinite;
}

@keyframes pf-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.pf-progress-step .pf-step-currency {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-left: auto;
}

/* Result banner */
.pf-progress-result {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
}

.pf-progress-result.success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.pf-progress-result.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Refresh button loading animation */
.btn-refresh .pf-spin {
  display: none;
}

.btn-refresh.loading .pf-spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* Responsive portfolio table */
@media (max-width: 768px) {
  .pf-capital-grid {
    grid-template-columns: 1fr;
  }

  .pf-table th,
  .pf-table td {
    padding: 8px 8px;
    font-size: 0.78rem;
  }

  .pf-name {
    font-size: 0.8rem;
  }
}

/* Chart area — cadre paysage fixe */
.pf-chart-area {
  padding: 12px 20px 8px;
  height: 220px;
  box-sizing: border-box;
  position: relative;
}

.pf-chart-area canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ============================================================
   Agents Analysts — Sidebar + 4 Agent Cards
   ============================================================ */

.analysts-view {
  animation: fadeIn 0.2s ease;
  margin-left: -100px;
}

/* Layout: sidebar left + main right */
.aa-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-left: 0;
}

/* Left sidebar — stock list */
.aa-stock-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: sticky;
  top: 24px;
}

.aa-stock-list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.aa-stock-list {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 4px;
}

.aa-stock-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.aa-stock-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-muted);
}

.aa-stock-item.active {
  background: rgba(75, 139, 255, 0.1);
  border-color: var(--accent-blue);
}

.aa-stock-ticker {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.aa-stock-price {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.aa-stock-meta {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 500;
}

.aa-stock-meta .up { color: var(--accent-green); }
.aa-stock-meta .down { color: var(--accent-red); }

/* Right — agents main area */
.aa-agents-main {
  flex: 1;
  min-width: 0;
}

/* Default message (no stock selected) */
.aa-default-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.aa-default-message svg {
  opacity: 0.25;
  margin-bottom: 16px;
}

.aa-default-message h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.aa-default-message p {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Agent grid 2x2 */
.aa-agent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Agent header bar */
.aa-agent-header-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.aa-agent-header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.aa-agent-ticker {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.aa-agent-company {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.aa-agent-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aa-agent-price {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.aa-agent-change {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.aa-agent-change.up { color: var(--accent-green); }
.aa-agent-change.down { color: var(--accent-red); }

/* Agent card */
.aa-agent-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.aa-agent-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.06);
}

.aa-agent-card-header svg {
  opacity: 0.5;
}

.aa-agent-card-body {
  padding: 4px 0;
  min-height: 60px;
}

.aa-agent-card-body .skeleton {
  margin: 12px 16px;
}

/* Fundamentals grid */
.aa-fund-grid {
  display: flex;
  flex-direction: column;
}

.aa-fund-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

.aa-fund-row:last-child {
  border-bottom: none;
}

.aa-fund-label {
  color: var(--text-muted);
}

.aa-fund-value {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Technique grid */
.aa-tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.aa-tech-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

.aa-tech-item:nth-child(2n) {
  border-right: none;
}

.aa-tech-item:nth-last-child(-n+2) {
  border-bottom: none;
}

.aa-tech-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.aa-tech-val {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.aa-tech-val.rsi-high { color: var(--accent-red); }
.aa-tech-val.rsi-low { color: var(--accent-green); }

/* Sentiment */
.aa-sent-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.aa-sent-subtitle {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 16px 4px;
}

.aa-st-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 16px;
  font-size: 0.78rem;
  line-height: 1.35;
  border-bottom: 1px solid var(--border-subtle);
}

.aa-st-msg:last-child {
  border-bottom: none;
}

.aa-st-user {
  font-weight: 600;
  color: var(--accent-blue);
  white-space: nowrap;
  font-size: 0.72rem;
}

.aa-st-body {
  color: var(--text-secondary);
  word-break: break-word;
}

.aa-rd-post {
  padding: 4px 16px;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-subtle);
}

.aa-rd-post:last-child {
  border-bottom: none;
}

/* Bull/Bear card */
.aa-bullbear-content {
  padding: 12px 16px;
}

.aa-bb-bull, .aa-bb-bear {
  margin-bottom: 10px;
}

.aa-bb-label {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.aa-bb-bull p, .aa-bb-bear p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.aa-bb-prompt {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

.aa-bb-prompt code {
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent-blue);
}

/* Responsive */
@media (max-width: 900px) {
  .aa-layout {
    flex-direction: column;
  }
  .aa-stock-sidebar {
    width: 100%;
    position: static;
  }
  .aa-stock-list {
    max-height: 200px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
  }
  .aa-stock-item {
    width: calc(50% - 4px);
  }
  .aa-agent-grid {
    grid-template-columns: 1fr;
  }
}