@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700&display=swap');

/* Default Theme Definitions */
body.theme-emerald {
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --bg-tertiary: #1e293b;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(16, 185, 129, 0.15);
  --accent: #10b981;
  --accent-rgb: 16, 185, 129;
  --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --accent-hover: #34d399;
  --accent-glow: rgba(16, 185, 129, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

body.theme-ocean {
  --bg-primary: #020617;
  --bg-secondary: #0f172a;
  --bg-tertiary: #1e293b;
  --card-bg: rgba(15, 23, 42, 0.7);
  --card-border: rgba(59, 130, 246, 0.18);
  --accent: #3b82f6;
  --accent-rgb: 59, 130, 246;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

body.theme-cyberpunk {
  --bg-primary: #05010d;
  --bg-secondary: #120224;
  --bg-tertiary: #240442;
  --card-bg: rgba(18, 2, 36, 0.65);
  --card-border: rgba(236, 72, 153, 0.22);
  --accent: #ec4899;
  --accent-rgb: 236, 72, 153;
  --accent-gradient: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  --accent-hover: #f472b6;
  --accent-glow: rgba(236, 72, 153, 0.4);
  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;
  --success: #06b6d4;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --card-shadow: 0 10px 30px -10px rgba(236, 72, 153, 0.15);
}

body.theme-rose-gold {
  --bg-primary: #0d0b0c;
  --bg-secondary: #161214;
  --bg-tertiary: #272023;
  --card-bg: rgba(22, 18, 20, 0.7);
  --card-border: rgba(199, 125, 142, 0.25);
  --accent: #c77d8e;
  --accent-rgb: 199, 125, 142;
  --accent-gradient: linear-gradient(135deg, #e0b1cb 0%, #9f86c0 100%);
  --accent-hover: #e0b1cb;
  --accent-glow: rgba(199, 125, 142, 0.35);
  --text-primary: #fcfafb;
  --text-secondary: #9fa0a4;
  --success: #a3b18a;
  --danger: #e07a5f;
  --warning: #f2cc8f;
  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg-secondary);
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

/* Elegant Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

/* Full Glassmorphic App Wrapper */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header & Navbar Styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-section h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-section p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Tab buttons and Navigation */
.nav-tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  padding: 0.35rem;
  gap: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 2.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.75rem 1.25rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.tab-btn.active {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* Glassmorphism Cards */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.6), 0 0 15px rgba(var(--accent-rgb), 0.1);
}

/* Dashboard Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.summary-card {
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
}

.summary-card.negative::before {
  background: var(--danger);
}

.summary-card.positive::before {
  background: var(--success);
}

.summary-card h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.summary-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
}

.summary-card .sub-value {
  font-size: 0.8rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Charts & Widgets Layout */
.dashboard-details {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 968px) {
  .dashboard-details {
    grid-template-columns: 1fr;
  }
}

.performance-leaders {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leader-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.leader-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.leader-val {
  font-weight: 700;
  font-size: 0.95rem;
}

/* Tables Styling */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background-color: var(--bg-secondary);
  max-height: 550px; /* Enable vertical scroll if needed */
  position: relative;
  cursor: grab;
}

.table-container:active {
  cursor: grabbing;
}

/* Table horizontal scrollbar styling */
.table-container::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover, #059669);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

/* Sticky table header and freeze-scroll 1st column */
#stocks-table,
#mfs-table,
#signals-table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1000px;
  width: 100%;
}

/* Sticky top headers for all columns */
#stocks-table th,
#mfs-table th,
#signals-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--bg-secondary) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Sticky 1st Column (Scrip / Fund Name) - Body Cells */
#stocks-table td:first-child,
#mfs-table td:first-child,
#signals-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 15;
  background-color: var(--bg-secondary) !important;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.3);
}

/* Sticky 1st Column (Scrip / Fund Name) - Header Cell (Sticks to Top 0 & Left 0) */
#stocks-table th:first-child,
#mfs-table th:first-child,
#signals-table th:first-child {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 25;
  background-color: var(--bg-secondary) !important;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.3);
}

/* 1st column sizing */
#stocks-table th:first-child,
#stocks-table td:first-child,
#mfs-table th:first-child,
#mfs-table td:first-child,
#signals-table th:first-child,
#signals-table td:first-child {
  min-width: 160px;
  max-width: 220px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

#stocks-table tr:hover td:first-child,
#mfs-table tr:hover td:first-child,
#signals-table tr:hover td:first-child {
  background-color: #1e1b2e !important;
}

th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

tr:hover td {
  background-color: rgba(var(--accent-rgb), 0.03);
}

.positive {
  color: var(--success) !important;
}

.negative {
  color: var(--danger) !important;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.ltcg {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge.stcg {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* Button UI */
.btn {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.25rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px var(--accent-glow);
}

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

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Interactive Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

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

/* Form Styles */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.form-control {
  width: 100%;
  background-color: var(--bg-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Live Updater Widget */
.updater-widget {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.08) 0%, rgba(255, 255, 255, 0) 100%);
  border: 1px dashed rgba(var(--accent-rgb), 0.3);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.updater-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-grow: 1;
}

.updater-progress-bg {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.updater-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  transition: width 0.4s ease;
}

.updater-logs {
  font-family: monospace;
  font-size: 0.75rem;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 0.5rem;
  border-radius: 6px;
  max-height: 80px;
  overflow-y: auto;
  margin-top: 0.5rem;
  color: #38bdf8;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Settings Column customizer list */
.column-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
  background-color: rgba(255, 255, 255, 0.01);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.checkbox-label:hover {
  color: var(--text-primary);
}

.checkbox-label input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* Theme picker UI */
.theme-picker-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.theme-option {
  flex: 1;
  min-width: 120px;
  padding: 1rem;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.05);
  background-color: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
}

.theme-option.active {
  border-color: var(--accent);
  background-color: rgba(var(--accent-rgb), 0.08);
  box-shadow: 0 0 10px var(--accent-glow);
}

.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin: 0 auto 0.5rem;
}

/* Widget Toggles list */
.widget-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.widget-toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Custom Alert Banner — 4-tier Severity System */
#alerts-container {
  margin-bottom: 0.75rem;
}

/* Critical (40%+ concentration or 35%+ drawdown) — Red */
.alert-banner-critical {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Warning (20-40% concentration or 20-35% drawdown) — Amber */
.alert-banner-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Low Severity (10-20% drawdown) — Yellow */
.alert-banner-low {
  background-color: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.22);
  color: #facc15;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Info — Blue */
.alert-banner-info {
  background-color: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: #60a5fa;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Legacy aliases (kept for compatibility) */
.alert-banner-red    { background-color:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.35);color:#f87171;padding:0.75rem 1rem;border-radius:8px;font-size:0.85rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;margin-bottom:0.5rem; }
.alert-banner-orange { background-color:rgba(245,158,11,0.1);border:1px solid rgba(245,158,11,0.3);color:#fbbf24;padding:0.75rem 1rem;border-radius:8px;font-size:0.85rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;margin-bottom:0.5rem; }
.alert-banner-yellow { background-color:rgba(234,179,8,0.08);border:1px solid rgba(234,179,8,0.22);color:#facc15;padding:0.75rem 1rem;border-radius:8px;font-size:0.85rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;margin-bottom:0.5rem; }

.alert-review-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.alert-review-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Strategic Priority Row Radar & Badges */
.priority-high-row td {
  background-color: rgba(239, 68, 68, 0.06) !important;
  border-left: 3px solid var(--danger);
}
.priority-medium-row td {
  background-color: rgba(245, 158, 11, 0.03) !important;
  border-left: 3px solid var(--warning);
}
.badge.warning-badge {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* Premium Profile Manager Styles */
.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.profile-item:hover {
  background-color: rgba(var(--accent-rgb), 0.05);
  border-color: rgba(var(--accent-rgb), 0.2);
  transform: translateX(3px);
}

.profile-item.active {
  background-color: rgba(var(--accent-rgb), 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.profile-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

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

.profile-item-status {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.profile-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-profile-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-profile-delete:hover {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.1);
}

.btn-profile-rename {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-profile-rename:hover {
  color: var(--accent);
  background-color: rgba(var(--accent-rgb), 0.1);
}

/* Performance Chart Period Toggle Buttons */
.perf-period-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.2s ease;
}
.perf-period-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}
.perf-period-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════════════════════
   MF Holdings Tab Redesign Styles
═══════════════════════════════════════════════════════════════════ */

/* ST / LT Holding Period Badges */
.badge-st {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background-color: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.3);
  margin-left: 0.4rem;
  vertical-align: middle;
}

.badge-lt {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* Sortable Table Headers */
.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  padding-right: 1.4rem !important;
}
.th-sortable:after {
  content: '⇅';
  position: absolute;
  right: 0.4rem;
  opacity: 0.4;
  font-size: 0.75rem;
}
.th-sortable.th-asc:after {
  content: '↑';
  opacity: 1;
  color: var(--accent);
}
.th-sortable.th-desc:after {
  content: '↓';
  opacity: 1;
  color: var(--accent);
}

/* MF Filter Bar */
.mf-filter-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.mf-filter-select {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  cursor: pointer;
  min-width: 130px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
.mf-filter-select:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.5);
}

/* MF Summary Footer */
.mf-summary-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  align-items: center;
  padding: 1rem 1.25rem;
  margin-top: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.mf-summary-footer strong {
  color: var(--text-primary);
  font-weight: 700;
}
.mf-summary-footer .footer-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.mf-summary-footer .footer-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
}

/* Fund Detail Drawer (slide-in from right) */
.mf-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.mf-drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.mf-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 420px;
  max-width: 95vw;
  background: var(--card-bg);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
  z-index: 2001;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mf-detail-drawer.open {
  transform: translateX(0);
}

.mf-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.mf-drawer-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin: 0;
}
.mf-drawer-header p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.2rem 0 0;
}
.mf-drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 1rem;
  transition: color 0.2s;
}
.mf-drawer-close:hover { color: var(--text-primary); }

.mf-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}
.mf-drawer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.875rem;
}
.mf-drawer-row:last-child { border-bottom: none; }
.mf-drawer-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.mf-drawer-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}
.mf-drawer-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin: 1.25rem 0 0.5rem;
}
.mf-drawer-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Fund Name clickable in table */
.mf-fund-link {
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
.mf-fund-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

#card-total-value {
  overflow: visible !important;
}

/* Breakdown Tooltip for Combined Portfolio */
.breakdown-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  width: 200px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 255, 255, 0.02);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translate(-50%, 6px);
  z-index: 100;
}

#card-total-value:hover .breakdown-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.breakdown-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(17, 24, 39, 0.95) transparent transparent transparent;
}

.breakdown-tooltip .tooltip-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
}

.breakdown-tooltip .tooltip-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  text-align: left;
}

.breakdown-tooltip .tooltip-row:last-child {
  margin-bottom: 0;
}

.breakdown-tooltip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.5rem;
  display: inline-block;
}

.breakdown-tooltip .stocks-dot {
  background-color: #ec4899; /* Pink */
}

.breakdown-tooltip .mfs-dot {
  background-color: #ffffff; /* White */
}

.breakdown-tooltip .label {
  color: var(--text-secondary);
  flex: 1;
}

.breakdown-tooltip .val {
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
}

/* Professional select options styling for dark theme */
select option {
  background-color: #111827;
  color: var(--text-primary);
}

/* Premium Mobile View Layout Adjustments */
@media (max-width: 768px) {
  /* Main Container Padding */
  .app-container {
    padding: 1rem 0.75rem;
  }

  /* Header Navigation */
  header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1.25rem !important;
    text-align: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
  }

  .logo-section h1 {
    font-size: 1.6rem;
    justify-content: center;
  }

  .header-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }

  .header-actions button,
  .header-actions .btn,
  .header-actions select {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Real-time scraper widget mobile stacking */
  .updater-widget {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }

  /* Navigation Tabs: Horizontal Scroll with hidden scrollbar */
  .nav-tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem !important;
    padding: 0.25rem !important;
    margin-bottom: 1.75rem !important;
    scrollbar-width: none; /* Hide scrollbar Firefox */
  }

  .nav-tabs::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari/Webkit */
  }

  .tab-btn {
    padding: 0.6rem 1rem !important;
    font-size: 0.85rem !important;
    flex-shrink: 0 !important;
  }

  /* Summary Metrics Cards Grid */
  .summary-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin-bottom: 1.75rem !important;
  }

  .summary-card {
    min-height: auto !important;
    padding: 1.25rem !important;
  }

  .summary-card .value {
    font-size: 1.5rem !important;
  }

  /* Card Headings and Tooltips */
  .breakdown-tooltip {
    width: 90%;
    max-width: 260px;
  }

  /* Flex widgets & details section stacking */
  .dashboard-details {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin-bottom: 1.75rem !important;
  }

  /* Stacking chart headers */
  #widget-performance-chart > div:first-child,
  #widget-sector-contribution-chart > div:first-child,
  .tab-content .card > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }

  #widget-performance-chart > div:first-child > div:last-child,
  #widget-sector-contribution-chart > div:first-child > div:last-child,
  .tab-content .card > div:first-child > div:last-child {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }

  #widget-performance-chart > div:first-child > div:last-child select,
  #widget-performance-chart > div:first-child > div:last-child button,
  #widget-performance-chart > div:first-child > div:last-child div,
  #widget-sector-contribution-chart > div:first-child > div:last-child button,
  #widget-sector-contribution-chart > div:first-child > div:last-child div,
  .tab-content .card > div:first-child > div:last-child input,
  .tab-content .card > div:first-child > div:last-child button,
  .tab-content .card > div:first-child > div:last-child div {
    width: 100% !important;
    max-width: none !important;
    justify-content: center !important;
  }

  /* Sector contribution summary row stacking */
  #contrib-summary-row {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    text-align: center !important;
  }

  /* Chart height limiter on mobile */
  canvas {
    max-height: 250px !important;
  }

  #chart-sector-contribution {
    max-height: 120px !important;
  }

  /* Modals scaling */
  .modal-content {
    width: 95% !important;
    padding: 1.5rem 1.25rem !important;
    margin: 0 auto;
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

/* Mobile Scroll Hint Indicator */
.scroll-hint {
  display: none;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .scroll-hint {
    display: block;
  }

  /* Make table container scrollable */
  .table-container,
  .stocks-table-wrapper,
  [class*="table-wrap"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
    width: 100% !important;
  }

  #stocks-table,
  #mfs-table,
  #signals-table {
    min-width: 900px !important;
  }

  /* Freeze header row */
  #stocks-table thead,
  #mfs-table thead,
  #signals-table thead,
  .table-container table thead,
  table thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background-color: var(--bg-secondary) !important;
  }

  #stocks-table thead th,
  #mfs-table thead th,
  #signals-table thead th,
  .table-container table thead th,
  table thead th,
  table th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background-color: var(--bg-secondary) !important;
    min-width: 90px;
    font-size: 12px !important;
    padding: 8px 6px !important;
    white-space: nowrap !important;
  }

  table td {
    min-width: 90px;
    font-size: 12px !important;
    padding: 8px 6px !important;
    white-space: nowrap !important;
  }

  /* Freeze first column (Scrip Name) */
  #stocks-table thead th:first-child,
  #stocks-table tbody td:first-child,
  #mfs-table thead th:first-child,
  #mfs-table tbody td:first-child,
  #signals-table thead th:first-child,
  #signals-table tbody td:first-child,
  .table-container table thead th:first-child,
  .table-container table tbody td:first-child,
  table thead th:first-child,
  table tbody td:first-child {
    position: sticky !important;
    left: 0 !important;
    z-index: 11 !important;
    background-color: var(--bg-secondary) !important;
    min-width: 120px !important;
    max-width: 130px !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.3) !important;
  }

  /* Header frozen first column needs higher z-index */
  #stocks-table thead th:first-child,
  #mfs-table thead th:first-child,
  #signals-table thead th:first-child,
  .table-container table thead th:first-child,
  table thead th:first-child {
    z-index: 12 !important;
    top: 0 !important;
    left: 0 !important;
  }

  /* Numeric columns can be narrower */
  table th:nth-child(4),
  table td:nth-child(4),
  table th:nth-child(5),
  table td:nth-child(5) {
    min-width: 80px;
  }
}
}

/* Real-time Status Dot Styles */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.status-dot.idle {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.running,
.status-dot.background_running {
  background-color: var(--warning);
  animation: status-pulse 1.5s infinite ease-in-out;
}

.status-dot.locked {
  background-color: var(--danger);
  animation: status-pulse-danger 2s infinite ease-in-out;
}

.status-dot.error {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes status-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    transform: scale(0.95);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    transform: scale(0.95);
  }
}

@keyframes status-pulse-danger {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    transform: scale(0.95);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    transform: scale(0.95);
  }
}

/* Mutual Fund summary card custom padding */
#card-mf-value {
  padding-top: 1.75rem !important;
  padding-bottom: 1.75rem !important;
}

.plan-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
  vertical-align: middle;
}

.plan-free {
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.2);
}

.plan-pro {
  background: linear-gradient(
    135deg, #667eea, #764ba2);
  color: white;
  border: none;
}

.plan-wealth {
  background: linear-gradient(
    135deg, #f6d365, #fda085);
  color: white;
  border: none;
}

.locked-feature {
  opacity: 0.5;
  cursor: not-allowed !important;
  position: relative;
  pointer-events: none; /* Make tab link unclickable */
}

.locked-feature::after {
  content: '🔒';
  margin-left: 4px;
  font-size: 10px;
}

/* ─── Account Settings Page ─────────────────────────────────────── */
.account-container {
  max-width: 760px;
  margin: 0 auto;
}

.account-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.account-card:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
}

.account-card-title {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.danger-zone {
  border-color: rgba(239, 68, 68, 0.35) !important;
}

.danger-zone:hover {
  border-color: rgba(239, 68, 68, 0.55) !important;
}

.danger-zone .account-card-title {
  color: var(--danger);
}

.plan-feature-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.plan-feature-list li {
  padding: 5px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.plan-feature-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  font-size: 0.8rem;
  width: 16px;
  flex-shrink: 0;
}

.plan-feature-list li.locked::before {
  content: '✗';
  color: var(--danger);
}

.account-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  transition: color 0.2s ease;
}

.account-back-link:hover {
  color: var(--accent);
}

.account-page-title {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.25rem;
  font-family: 'Outfit', sans-serif;
}

.account-page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.account-field-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.account-field-row .form-control {
  flex: 1;
}

.account-field-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.4rem;
  display: block;
}

.account-verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.account-readonly-field {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  width: 100%;
}

.plan-card-inner {
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: 12px;
  padding: 1.25rem;
}

.plan-card-inner.plan-pro-card {
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.08) 100%);
  border-color: rgba(102,126,234,0.3);
}

.plan-badge-large {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.plan-badge-large.free {
  background: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.2);
}

.plan-badge-large.pro {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.account-alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: accountAlertIn 0.3s ease;
}

.account-alert.success {
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.3);
  color: #34d399;
}

.account-alert.error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171;
}

@keyframes accountAlertIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* User dropdown in header */
.account-user-dropdown {
  position: relative;
}

.account-user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 200;
  overflow: hidden;
}

.account-user-dropdown.open .account-user-dropdown-menu {
  display: block;
  animation: accountAlertIn 0.2s ease;
}

.account-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.account-dropdown-item:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text-primary);
}

.account-dropdown-item.danger:hover {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.account-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}

.account-user-trigger:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04);
}

/* Member since info row */
.account-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.875rem;
}

.account-info-row:last-child {
  border-bottom: none;
}

.account-info-key {
  color: var(--text-secondary);
}

.account-info-val {
  color: var(--text-primary);
  font-weight: 500;
}

/* ════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS  ≤ 768px  →  ≤ 480px
   ════════════════════════════════════════════════════ */

/* ── 768px: tablet-level tweaks ─────────────────── */
@media (max-width: 768px) {
  .app-container {
    padding: 1.25rem 1rem;
  }

  header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .logo-section h1 {
    font-size: 1.3rem;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 1.5rem;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }

  .tab-btn {
    flex-shrink: 0;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  .card {
    padding: 1.25rem;
  }
}

/* ── 480px: phone-level fixes ────────────────────── */
@media (max-width: 480px) {

  /* 1 ── APP WRAPPER */
  .app-container {
    padding: 1rem 0.75rem;
  }

  /* 2 ── HEADER
     Layout: [Logo] ... [Name+Badge] [Chevron]
     Hide price-status pill and Theme button       */
  header {
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    align-items: center;
  }

  .logo-section h1 {
    font-size: 1.1rem;
    gap: 0.3rem;
  }
  /* Keep logo text visible but compact on mobile */
  .logo-section h1 .logo-text {
    display: inline;
    font-size: 0.9rem;
  }

  .header-actions {
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Keep price-status pill visible & responsive on mobile */
  #price-status-container {
    display: flex !important;
    padding: 0.25rem 0.5rem !important;
  }

  /* Keep Theme button visible & responsive on mobile */
  #btn-theme-toggle {
    display: inline-flex !important;
  }

  /* Compact user trigger */
  .account-user-trigger {
    padding: 3px 8px;
    font-size: 0.78rem;
    gap: 0.25rem;
  }

  /* 3 ── TAB NAVIGATION: force horizontal scroll, no wrap */
  .nav-tabs {
    overflow-x: scroll !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap !important;
    padding: 0.25rem;
    gap: 0.15rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }

  .tab-btn {
    flex-shrink: 0 !important;
    min-width: fit-content;
    padding: 0.45rem 0.75rem !important;
    font-size: 11px !important;
    white-space: nowrap;
    gap: 0.3rem;
  }

  /* 4 ── CARDS */
  .card {
    padding: 1rem;
    border-radius: 12px;
  }

  /* 5 ── SUMMARY CARDS */
  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .summary-card {
    padding: 0.9rem 0.9rem 0.9rem 1.25rem;
  }

  .summary-card h3 {
    font-size: 0.72rem;
    letter-spacing: 0.03em;
  }

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

  .summary-card .sub-value {
    font-size: 0.72rem;
  }

  /* 6 ── PERFORMANCE CHART
     Stack benchmark dropdown above period toggles  */
  #widget-performance-chart > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  /* Period toggle row: full width */
  #widget-performance-chart div[style*="display:flex"][style*="gap:0.3rem"],
  #widget-performance-chart div[style*="display: flex"][style*="gap: 0.3rem"] {
    width: 100%;
    justify-content: space-between;
  }

  .perf-period-btn {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.3rem;
    font-size: 0.75rem;
  }

  /* Chart: constrain the parent wrapper, not the canvas.
     Chart.js ignores CSS height on <canvas> — control the container div instead. */
  #widget-performance-chart div[style*="position:relative"],
  #widget-performance-chart div[style*="position: relative"] {
    height: 220px !important;
    max-height: 220px !important;
    min-height: 160px;
  }

  /* Sector contribution chart */
  #contrib-chart-container {
    height: 90px !important;
  }

  /* Contribution legend: single column */
  #contrib-legend {
    gap: 0.6rem !important;
    font-size: 11px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* Contribution summary row: stack */
  #contrib-summary-row {
    grid-template-columns: 1fr !important;
    gap: 0.6rem !important;
    text-align: left !important;
  }

  /* 7 ── ALERT BANNERS */
  .alert-banner-critical,
  .alert-banner-warning,
  .alert-banner-low,
  .alert-banner-info,
  .alert-banner-red,
  .alert-banner-orange,
  .alert-banner-yellow {
    font-size: 0.78rem;
    padding: 0.6rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .alert-review-btn {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  /* Plan limit banner */
  #plan-limit-banner {
    font-size: 0.78rem;
    padding: 0.6rem 0.75rem;
  }

  /* 8 ── SECTOR ALLOCATION CHART
     Donut above legend, legend in 2-col grid       */
  #widget-sector-chart-box .card,
  #widget-sector-chart-box {
    overflow: visible;
  }

  /* The canvas container + legend stack vertically */
  #widget-sector-chart-box > div[style*="position: relative"],
  #widget-sector-chart-box > div[style*="position:relative"] {
    height: 200px !important;
  }

  /* 9 ── PORTFOLIO CONTEXT STRIP */
  #portfolio-context-strip {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    gap: 0.75rem !important;
    padding: 0.65rem 0.875rem !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #portfolio-context-strip::-webkit-scrollbar { display: none; }

  #portfolio-context-strip > div[style*="width: 1px"],
  #portfolio-context-strip > div[style*="width:1px"] {
    display: block !important;
    flex-shrink: 0;
  }

  #portfolio-context-strip > div {
    flex-shrink: 0;
  }

  /* 10 ── STOCKS / MF TABLE toolbar */
  #tab-stocks .card > div:first-child,
  #tab-mfs .card > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  #tab-stocks .card > div > div[style*="display: flex"],
  #tab-mfs .card > div > div[style*="display: flex"] {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* 11 ── MF FILTER BAR */
  .mf-filter-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .mf-filter-select,
  #mf-search,
  #stock-search {
    width: 100%;
    max-width: 100% !important;
  }

  /* 12 ── MF SUMMARY FOOTER */
  .mf-summary-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .footer-divider { display: none; }

  /* 13 ── ACCOUNT PAGE */
  .account-container {
    padding: 0;
  }

  .account-card {
    padding: 1rem;
    border-radius: 12px;
  }

  .account-field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .account-field-row .btn,
  .account-field-row button {
    width: 100%;
    justify-content: center;
  }

  .account-card .btn,
  .account-card .btn-secondary,
  .account-card .btn-danger {
    width: 100%;
    justify-content: center;
  }

  /* Plan feature list more compact */
  .plan-feature-list li {
    font-size: 0.8rem;
    padding: 4px 0;
  }

  /* Delete modal */
  .modal-content {
    padding: 1.25rem;
    margin: 0 0.5rem;
    width: calc(100% - 1rem);
  }

  /* 14 ── SIGNALS TABLE */
  #tab-signals .card > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  #signal-search {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 15 ── VISUAL SETTINGS FORM */
  .form-row {
    grid-template-columns: 1fr;
  }

  .theme-picker-group {
    grid-template-columns: 1fr 1fr;
  }

  /* 16 ── DASHBOARD DETAILS: single col already from 968px rule,
     but reduce gap on mobile */
  .dashboard-details {
    gap: 1rem;
  }
}

