/* ═══════════════════════════════════════════════════════
   Indian Stock Market Analyzer - StockPulse
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1e2a40;
  --bg-input: #1e293b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --green: #22c55e;
  --green-soft: #16a34a;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #ef4444;
  --red-soft: #dc2626;
  --red-bg: rgba(239, 68, 68, 0.1);
  --orange: #f59e0b;
  --orange-bg: rgba(245, 158, 11, 0.1);
  --purple: #a855f7;
  --border: #1e293b;
  --border-light: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

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

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

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.logo i {
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.header-center {
  flex: 1;
  max-width: 500px;
  margin: 0 24px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  z-index: 200;
}

.search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.search-result-item:hover {
  background: var(--bg-card-hover);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.search-result-symbol {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
}

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

.market-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
}

.status-dot.open {
  background: var(--green);
  animation: pulse 2s infinite;
}

.status-dot.closed {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.refresh-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.refresh-btn:hover {
  background: var(--bg-card-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.refresh-btn.small {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.refresh-btn.spinning i {
  animation: spin 1s linear infinite;
}

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

/* ─── Auto Refresh Toggle ─── */
.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
}

.art-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.art-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

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

.art-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 18px;
  cursor: pointer;
  transition: 0.2s;
}

.art-slider:before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}

.art-switch input:checked + .art-slider {
  background: rgba(34,197,94,0.3);
  border: 1px solid var(--green);
}

.art-switch input:checked + .art-slider:before {
  transform: translateX(16px);
  background: var(--green);
}

/* ─── Indices Bar ─── */
.indices-bar {
  display: flex;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.index-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  min-width: 200px;
  border: 1px solid var(--border);
}

.index-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.index-price {
  font-size: 1rem;
  font-weight: 700;
}

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

.index-change.positive {
  color: var(--green);
}

.index-change.negative {
  color: var(--red);
}

/* ─── Main Content ─── */
.main-content {
  display: grid;
  grid-template-columns: 320px 1fr 380px;
  gap: 0;
  height: calc(100vh - 110px);
}

.panel {
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.panel:last-child {
  border-right: none;
}

.panel:last-child {
  border-right: none;
}

.left-panel {
  display: flex;
  flex-direction: column;
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.tab-btn {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-card);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

.sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.sort-bar select {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
}

.filter-btns {
  display: flex;
  gap: 4px;
}

.filter-btn {
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.filter-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

/* Stock List */
.stock-list {
  flex: 1;
  overflow-y: auto;
}

.stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.stock-item:hover {
  background: var(--bg-card);
}

.stock-item.active {
  background: var(--bg-card);
  border-left: 3px solid var(--accent-cyan);
}

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

.stock-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.stock-symbol {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stock-price-info {
  text-align: right;
}

.stock-price {
  font-size: 0.85rem;
  font-weight: 700;
}

.stock-change {
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.stock-change.positive {
  color: var(--green);
}

.stock-change.negative {
  color: var(--red);
}

.stock-change-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.stock-change-badge.positive {
  background: var(--green-bg);
  color: var(--green);
}

.stock-change-badge.negative {
  background: var(--red-bg);
  color: var(--red);
}

/* Sector List */
.sector-list {
  padding: 8px;
}

.sector-card {
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.sector-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.sector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sector-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.sector-change {
  font-weight: 700;
  font-size: 0.9rem;
}

.sector-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sector-arrow {
  font-size: 0.65rem;
  margin-left: 4px;
  opacity: 0.5;
  transition: var(--transition);
}

.sector-card:hover .sector-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.sector-picks-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  transition: var(--transition);
}

.sector-picks-back:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

/* Recommendation List */
.recommendation-list {
  padding: 8px;
}

.rec-card {
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.rec-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.rec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.rec-stock-info {
  flex: 1;
}

.rec-stock-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.rec-stock-price {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.rec-action-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.rec-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.rec-score-item {
  text-align: center;
  padding: 6px 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.rec-score-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rec-score-value {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 2px;
}

.rec-reasons {
  list-style: none;
  padding: 0;
}

.rec-reasons li {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 3px 0;
  line-height: 1.4;
}

.rec-total-score {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.score-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.score-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.score-value {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 30px;
  text-align: right;
}

/* ─── Center Panel ─── */
.center-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.selected-stock-info h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.stock-price-display {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 4px;
}

.stock-price-display .price {
  font-size: 1.8rem;
  font-weight: 800;
}

.stock-price-display .change {
  font-size: 1rem;
  font-weight: 600;
}

.chart-period-btns {
  display: flex;
  gap: 4px;
}

.period-btn {
  padding: 6px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
}

.period-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
}

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

.chart-with-sentiment {
  display: flex;
  gap: 12px;
  min-height: 350px;
  max-height: 480px;
}

.chart-container {
  flex: 1;
  min-height: 350px;
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

/* ─── Sentiment Panel (beside chart) ─── */
.sentiment-panel {
  width: 240px;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sentiment-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

.sentiment-loading i {
  font-size: 1.8rem;
  opacity: 0.4;
}

/* Sentiment Panel Inner Styles */
.sp-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}

.sp-score-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.sp-score-inner {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sp-score-num {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.sp-score-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.sp-action {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 14px;
  border: 2px solid;
  border-radius: 20px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.sp-confidence {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sp-confidence strong {
  color: var(--text-secondary);
}

/* Buy/Sell Pressure */
.sp-pressure {
  margin-bottom: 14px;
}

.sp-pressure-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sp-buy-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--green);
}

.sp-sell-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--red);
}

.sp-pressure-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
}

.sp-buy-bar {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  transition: width 0.5s ease;
}

.sp-sell-bar {
  background: linear-gradient(90deg, #ef4444, #dc2626);
  transition: width 0.5s ease;
}

/* Score Breakdown */
.sp-breakdown {
  margin-bottom: 12px;
}

.sp-breakdown-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sp-score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.sp-score-row-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  min-width: 72px;
  white-space: nowrap;
}

.sp-score-row-bar {
  flex: 1;
  height: 5px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.sp-score-row-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.sp-score-row-val {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 22px;
  text-align: right;
}

/* Risk */
.sp-risk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sp-risk-badge {
  font-weight: 700;
  padding: 2px 10px;
  border: 1px solid;
  border-radius: 20px;
  font-size: 0.68rem;
}

/* News Summary in Sentiment */
.sp-news-summary {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.sp-news-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.sp-news-counts {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.sp-news-bullish {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green);
}

.sp-news-neutral {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--orange);
}

.sp-news-bearish {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--red);
}

.sp-headlines {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sp-headline {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.sp-headline-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.sp-headline-text {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stock-details {
  margin-top: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.detail-item {
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.detail-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.detail-placeholder i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

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

/* ─── Horizon Analysis ─── */
.horizon-section {
  margin: 12px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.horizon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.horizon-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.horizon-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.ha-top {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.ha-verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.ha-verdict-icon { font-size: 1.2rem; }

.ha-verdict-label {
  font-size: 0.9rem;
  font-weight: 800;
}

.ha-verdict-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.ha-score-ring {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.ha-ring-svg {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.ha-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
}

.ha-projection {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
}

.ha-proj-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.ha-proj-label { color: var(--text-muted); }
.ha-proj-val { font-weight: 700; }

.ha-range {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.ha-range-label { color: var(--text-muted); }
.ha-range-val { color: var(--text-secondary); font-weight: 600; }

.ha-scores {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}

.ha-score-item { display: flex; flex-direction: column; gap: 3px; }

.ha-score-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.ha-score-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.ha-score-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.ha-risk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.ha-risk-badge {
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
}

.ha-vol { margin-left: auto; color: var(--text-muted); font-size: 0.68rem; }

.ha-reasons {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.ha-reasons-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ha-reasons-title.positive { color: var(--green); }
.ha-reasons-title.negative { color: var(--red); }

.ha-reasons ul {
  margin: 0;
  padding-left: 14px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ha-disclaimer {
  padding: 6px 14px;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-style: italic;
}

.stock-recommendation {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

.stock-rec-title {
  font-size: 0.9rem;
  font-weight: 700;
}

/* ─── Right Panel - News ─── */
.right-panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.news-search-bar i.fa-search {
  position: absolute;
  left: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.news-search-bar input {
  width: 100%;
  padding: 7px 32px 7px 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.news-search-bar input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.news-search-clear {
  position: absolute;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.75rem;
  transition: var(--transition);
}

.news-search-clear:hover { color: var(--text-primary); }
.news-search-clear.hidden { display: none; }

.news-filters {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.news-filter-btn {
  padding: 4px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.news-filter-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.news-list {
  flex: 1;
  overflow-y: auto;
}

.news-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.news-item:hover {
  background: var(--bg-card);
}

.news-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.news-source {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.news-time {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.news-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-summary {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.news-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.news-sentiment-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.news-related-stocks {
  display: flex;
  gap: 4px;
}

.news-stock-tag {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-input);
  color: var(--accent-cyan);
  border: 1px solid var(--border);
}

/* ─── Loading ─── */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 12px;
}

.loading-spinner i {
  font-size: 1.5rem;
  color: var(--accent-cyan);
}

.loading-placeholder {
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

/* ─── Utility ─── */
.hidden {
  display: none !important;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral { color: var(--orange) !important; }

/* ─── Responsive ─── */
@media (max-width: 1400px) {
  .main-content {
    grid-template-columns: 280px 1fr 340px;
  }
}

@media (max-width: 1100px) {
  .main-content {
    grid-template-columns: 260px 1fr;
  }
  .right-panel {
    display: none;
  }
}

/* ─── Tablet (768px) ─── */
@media (max-width: 768px) {
  /* Header */
  .header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header-left { gap: 10px; }
  .tagline { display: none; }
  .header-center {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    margin: 4px 0 0;
  }
  .header-right {
    gap: 8px;
  }
  .last-updated { display: none; }
  .nav-username { display: none; }

  /* Indices bar */
  .indices-bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .index-card {
    min-width: 150px;
    padding: 6px 12px;
  }

  /* Main layout: single column, auto height */
  .main-content {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }
  .panel:last-child { border-bottom: none; }

  /* Left panel */
  .left-panel { max-height: none; }

  /* Chart panel */
  .chart-with-sentiment {
    flex-direction: column;
    min-height: unset;
    max-height: unset;
  }
  .chart-container {
    height: 220px;
    min-height: unset;
    width: 100%;
    flex: none;
    box-sizing: border-box;
  }
  .center-panel {
    overflow-y: visible;
    padding: 10px;
    width: 100%;
  }
  .sentiment-panel {
    width: 100%;
    min-width: unset;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .chart-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  .chart-period-btns {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .period-btn {
    flex: 1;
    min-width: 40px;
  }

  /* Detail grid */
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Right panel: show it below, full width */
  .right-panel {
    display: block;
    max-height: 400px;
    overflow-y: auto;
  }

  /* Top 10 */
  .top10-section {
    padding: 12px;
  }
  .top10-card {
    padding: 10px;
  }

  /* Portfolio score card */
  .psc-ring {
    width: 70px;
    height: 70px;
  }
  .psc-ring-center {
    width: 52px;
    height: 52px;
  }
}

/* ─── Mobile (480px) ─── */
@media (max-width: 480px) {
  /* Header */
  .header { padding: 8px 12px; }
  .logo { font-size: 1.1rem; }
  .logo i { font-size: 1.2rem; }
  .refresh-btn span { display: none; }
  .logout-btn span { display: none; }
  .nav-link span { display: none; }
  .header-right { gap: 6px; }
  .market-status .status-text { display: none; }

  /* Indices */
  .index-card { min-width: 130px; padding: 6px 10px; }
  .index-price { font-size: 0.9rem; }
  .index-change { font-size: 0.72rem; }

  /* Tabs */
  .tab-btn {
    font-size: 0.7rem;
    padding: 10px 4px;
    gap: 3px;
  }
  .tab-btn i { font-size: 0.75rem; }

  /* Stock list items */
  .stock-item { padding: 10px 12px; }
  .stock-name { font-size: 0.82rem; }
  .stock-price { font-size: 0.88rem; }

  /* Chart */
  .chart-container { height: 180px; min-height: unset; }
  .chart-period-btns { gap: 3px; }
  .period-btn { font-size: 0.72rem; padding: 5px 6px; }

  /* Detail grid: 2 columns on mobile */
  .detail-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .detail-item { padding: 8px 10px; }
  .detail-value { font-size: 0.82rem; }

  /* Sentiment panel */
  .sp-signals-grid { grid-template-columns: 1fr; }
  .sp-header { flex-direction: column; align-items: center; text-align: center; gap: 8px; }

  /* Top 10 */
  .top10-scores-bar { flex-wrap: wrap; gap: 6px; }
  .top10-card { padding: 10px; }
  .top10-name { font-size: 0.82rem; }

  /* Rec scores */
  .rec-scores { grid-template-columns: repeat(2, 1fr); }

  /* Portfolio */
  .psummary-row { grid-template-columns: 1fr 1fr; }
  .psc-inner { gap: 12px; }
  .psc-stats { gap: 10px; }
  .psell-top { flex-direction: column; gap: 6px; }

  /* Sort bar */
  .sort-bar { flex-direction: column; gap: 8px; align-items: stretch; }
  .filter-btns { justify-content: center; }

  /* News */
  .news-item { padding: 10px 12px; }
  .news-title { font-size: 0.82rem; }

  /* Modal */
  .modal-content {
    margin: 10px;
    max-height: calc(100vh - 20px);
  }

  /* Sector card */
  .sector-card { padding: 10px 12px; }

  /* Stock recommendation */
  .rec-scores { gap: 6px; }
  .rec-score-item { padding: 6px 4px; }
}

/* ─── Small mobile (360px) ─── */
@media (max-width: 360px) {
  .tab-btn i { display: none; }
  .tab-btn { font-size: 0.68rem; }
  .index-card { min-width: 110px; }
  .chart-container { height: 160px; min-height: unset; }
  .psc-ring { width: 60px; height: 60px; }
  .psc-ring-center { width: 44px; height: 44px; }
  .psc-score-num { font-size: 1rem; }
}

/* ═══════════════════════════════════════════════════════
   Portfolio Section
   ═══════════════════════════════════════════════════════ */

.portfolio-section {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portfolio-add-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.portfolio-add-form h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.portfolio-form-row {
  margin-bottom: 8px;
  position: relative;
}

.portfolio-form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.portfolio-input-group {
  position: relative;
}

.portfolio-input-group label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.portfolio-input-group input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.portfolio-input-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.portfolio-input-group input::placeholder {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.portfolio-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 2px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow);
}

.portfolio-search-item {
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}

.portfolio-search-item:hover {
  background: var(--bg-card-hover);
}

.portfolio-search-item:last-child {
  border-bottom: none;
}

.psi-name {
  font-size: 0.8rem;
  font-weight: 500;
}

.psi-symbol {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 3px;
}

.portfolio-add-btn {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.portfolio-add-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ─── Portfolio Score Card ─── */
.portfolio-score-card {
  margin-bottom: 10px;
}

.psc-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.psc-ring-wrap {
  flex-shrink: 0;
}

.psc-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.psc-ring-center {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.psc-score-num {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.psc-score-sub {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.psc-meta {
  flex: 1;
  min-width: 0;
}

.psc-health-label {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.psc-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.psc-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.psc-stat-val {
  font-size: 1rem;
  font-weight: 800;
}

.psc-stat-lbl {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.psc-buy { color: var(--green); }
.psc-hold { color: var(--orange); }
.psc-sell { color: var(--red); }

.psc-pnl-row {
  font-size: 0.82rem;
}

.psc-pnl {
  font-weight: 700;
}

.psc-pnl.positive { color: var(--green); }
.psc-pnl.negative { color: var(--red); }

.psc-pnl-pct {
  font-size: 0.75rem;
  margin-left: 4px;
  opacity: 0.85;
}

/* ─── Sell Alerts ─── */
.portfolio-sell-alerts {
  margin-bottom: 10px;
}

.psell-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #f44336;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding: 0 2px;
}

.psell-count {
  margin-left: auto;
  background: rgba(244, 67, 54, 0.12);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 0.68rem;
}

.psell-card {
  background: rgba(244, 67, 54, 0.05);
  border: 1px solid rgba(244, 67, 54, 0.2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.psell-card:hover {
  background: rgba(244, 67, 54, 0.1);
}

.psell-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.psell-name-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.psell-name {
  font-size: 0.85rem;
  font-weight: 700;
}

.psell-qty {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.psell-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}

.psell-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.psell-price {
  font-size: 0.85rem;
  font-weight: 700;
}

.psell-pnl {
  font-size: 0.78rem;
  font-weight: 700;
}

.psell-pnl.positive { color: var(--green); }
.psell-pnl.negative { color: var(--red); }

.psell-scores {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.psell-reasons {
  margin: 0;
  padding: 0 0 0 14px;
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Portfolio Summary */
.psummary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.psummary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.psummary-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.psummary-value {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 2px;
}

.psummary-pnl {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.psummary-pnl.positive {
  background: var(--green-bg);
}

.psummary-pnl.negative {
  background: var(--red-bg);
}

.psummary-pnl-label {
  font-size: 0.75rem;
  font-weight: 700;
}

.psummary-pnl-value {
  font-size: 0.85rem;
  font-weight: 700;
}

.psummary-health {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.psummary-health-badge {
  font-weight: 700;
  padding: 2px 10px;
  border: 1px solid;
  border-radius: 20px;
  font-size: 0.72rem;
}

.psummary-score {
  margin-left: auto;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.psummary-actions {
  display: flex;
  gap: 8px;
}

.psa-item {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.psa-buy {
  background: var(--green-bg);
  color: var(--green);
}

.psa-hold {
  background: var(--orange-bg);
  color: var(--orange);
}

.psa-sell {
  background: var(--red-bg);
  color: var(--red);
}

/* Holdings List */
.portfolio-holdings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.portfolio-holdings-header h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.portfolio-analyze-btn {
  padding: 5px 12px;
  background: linear-gradient(135deg, var(--purple), var(--accent-blue));
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.portfolio-analyze-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.portfolio-holding-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.portfolio-holding-item:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

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

.phi-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phi-details {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.phi-invested {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.phi-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  transition: var(--transition);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.phi-remove:hover {
  color: var(--red);
  background: var(--red-bg);
}

.portfolio-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
  color: var(--text-muted);
  text-align: center;
  gap: 10px;
}

.portfolio-empty i {
  font-size: 2rem;
  opacity: 0.3;
}

.portfolio-empty p {
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Portfolio Recommendations */
.prec-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.prec-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.prec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.prec-stock {
  flex: 1;
}

.prec-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.prec-price {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.prec-action-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.prec-pnl {
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.prec-pnl.positive {
  background: var(--green-bg);
}

.prec-pnl.negative {
  background: var(--red-bg);
}

.prec-qty {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.8;
}

.prec-scores {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.prec-scores span {
  flex: 1;
  text-align: center;
  font-size: 0.72rem;
  padding: 4px 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.prec-reasons {
  list-style: none;
  padding: 0;
}

.prec-reasons li {
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 2px 0;
  line-height: 1.4;
}

/* Toast */
.portfolio-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--orange);
  color: var(--orange);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   Top 10 Suggestions Section
   ═══════════════════════════════════════════════════════ */

.top10-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
}

.top10-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.top10-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.top10-header h3 i {
  color: #f59e0b;
}

.top10-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.top10-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top10-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.top10-card:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.08);
}

.top10-rank {
  font-size: 1.3rem;
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--text-muted);
  background: var(--bg-input);
  border-radius: 8px;
  flex-shrink: 0;
}

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

.top10-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.top10-name {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top10-action {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.top10-price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.top10-price {
  font-size: 0.95rem;
  font-weight: 700;
}

.top10-change {
  font-size: 0.8rem;
  font-weight: 600;
}

.top10-score-badge {
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: auto;
  background: var(--bg-input);
  padding: 2px 10px;
  border-radius: 20px;
}

.top10-scores-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.top10-scores-bar span {
  flex: 1;
  text-align: center;
  font-size: 0.72rem;
  padding: 4px 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.top10-reasons {
  list-style: none;
  padding: 0;
  margin: 0;
}

.top10-reasons li {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 1px 0;
  line-height: 1.4;
}

.top10-reasons li::before {
  content: '→ ';
  color: var(--accent-cyan);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════
   Technical Signals in Sentiment Panel
   ═══════════════════════════════════════════════════════ */

.sp-tech-signals {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 12px;
}

.sp-tech-signals-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-tech-signals-title i {
  color: var(--accent-cyan);
}

.sp-signal-counts {
  margin-left: auto;
  display: flex;
  gap: 6px;
  font-size: 0.7rem;
}

.sp-sig-bull, .sp-sig-bear, .sp-sig-neut {
  font-weight: 600;
}

.sp-signals-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-signal-card {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  transition: var(--transition);
}

.sp-signal-card:hover {
  border-color: var(--border-light);
}

.sp-signal-card.sp-sig-bullish {
  border-left: 3px solid var(--green);
  background: rgba(34, 197, 94, 0.04);
}

.sp-signal-card.sp-sig-bearish {
  border-left: 3px solid var(--red);
  background: rgba(239, 68, 68, 0.04);
}

.sp-signal-card.sp-sig-neutral {
  border-left: 3px solid var(--orange);
  background: rgba(245, 158, 11, 0.04);
}

.sp-signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.sp-signal-name {
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sp-sig-bullish .sp-signal-name {
  color: var(--green);
}

.sp-sig-bearish .sp-signal-name {
  color: var(--red);
}

.sp-sig-neutral .sp-signal-name {
  color: var(--orange);
}

.sp-signal-name i {
  font-size: 0.65rem;
}

.sp-signal-value {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.sp-signal-detail {
  font-size: 0.66rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ═══════════════════════════════════════════════════════
   Auth — Login Page
   ═══════════════════════════════════════════════════════ */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.login-container {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.login-logo i { color: var(--accent-blue); }

.login-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.login-tabs {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
}

.login-tab-btn {
  flex: 1;
  padding: 0.55rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.login-tab-btn.active {
  background: var(--accent-blue);
  color: #fff;
}

.login-form-section { display: flex; flex-direction: column; gap: 1rem; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"] {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

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

.auth-submit-btn {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.auth-submit-btn:hover:not(:disabled) { background: #2563eb; }
.auth-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-error {
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
}

.auth-success {
  background: var(--green-bg);
  border: 1px solid rgba(34,197,94,0.3);
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
}

/* Header nav additions */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  transition: var(--transition);
  white-space: nowrap;
}

.nav-link:hover { color: var(--text-primary); border-color: var(--accent-blue); }

.nav-username {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.logout-btn:hover { color: var(--red); border-color: var(--red); }

.logo-link { text-decoration: none; }

/* Portfolio tab — transactions link */
.portfolio-tx-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-blue);
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  transition: var(--transition);
}

.portfolio-tx-link:hover { background: #2563eb; }

/* ═══════════════════════════════════════════════════════
   Transactions Page
   ═══════════════════════════════════════════════════════ */

.tx-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tx-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.tx-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tx-section-title i { color: var(--accent-blue); }

/* Holdings grid */
.holdings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.holdings-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
  grid-column: 1/-1;
}

.holding-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.holding-symbol {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-blue);
  letter-spacing: 0.5px;
}

.holding-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holding-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.holding-stat span { color: var(--text-muted); }
.holding-stat strong { color: var(--text-primary); }

/* Add transaction form */
.tx-form-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tx-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.tx-form-row .form-group { flex: 1; min-width: 140px; }

.search-wrapper { position: relative; }

.tx-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.tx-search-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s;
}

.tx-search-item:hover { background: var(--bg-card-hover); }

.tx-search-symbol {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-blue);
  min-width: 80px;
}

.tx-search-name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Type toggle */
.tx-type-toggle {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.tx-type-btn {
  flex: 1;
  padding: 0.55rem 0.5rem;
  background: transparent;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.tx-type-btn.active.buy  { background: var(--green-bg);  color: var(--green); }
.tx-type-btn.active.sell { background: var(--red-bg);    color: var(--red); }

/* Preview + submit row */
.tx-form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.tx-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tx-preview strong { color: var(--text-primary); font-size: 1rem; }

.tx-submit { margin-top: 0; }

/* Transaction table */
.tx-table-wrapper { overflow-x: auto; }

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.tx-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.tx-table td {
  padding: 0.65rem 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tx-table tr:last-child td { border-bottom: none; }
.tx-table tr:hover td { background: var(--bg-card-hover); }

.tx-stock-name { color: var(--text-primary); font-weight: 600; }
.tx-stock-symbol { color: var(--text-muted); font-size: 0.72rem; }

.tx-type-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tx-type-badge.buy  { background: var(--green-bg);  color: var(--green); }
.tx-type-badge.sell { background: var(--red-bg);    color: var(--red); }

.tx-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

.tx-delete-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
}

.tx-delete-btn:hover { color: var(--red); border-color: var(--red); }

/* Transactions page header */
.header-right { gap: 0.5rem; }

