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

:root {
  /* Color Tokens */
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.45);
  --bg-card-hover: rgba(30, 41, 59, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-glow: rgba(99, 102, 241, 0.15);
  --accent-success: #10b981; /* Emerald Green */
  --accent-success-glow: rgba(16, 185, 129, 0.15);
  --accent-danger: #f43f5e; /* Rose Red */
  --accent-danger-glow: rgba(244, 63, 94, 0.15);
  --accent-warning: #f59e0b; /* Amber */
  
  --sidebar-width: 260px;
  --header-height: 70px;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --border-radius: 16px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Sidebar */
aside.sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 23, 42, 0.8);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.logo-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-radius: 12px;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: var(--transition-smooth);
}

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

.nav-item.active .nav-link {
  color: var(--text-primary);
  background: var(--accent-primary-glow);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.05);
}

.nav-item.active .nav-link svg {
  color: var(--accent-primary);
  filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.5));
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-success);
  animation: pulse 2s infinite;
}

.pulse-dot.agent-thinking {
  background-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

/* Main Content Area */
main.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: rgba(9, 13, 22, 0.3);
}

/* Header */
header.top-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.portfolio-quick-stats {
  display: flex;
  align-items: center;
  gap: 24px;
}

.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.quick-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-stat-value {
  font-size: 16px;
  font-weight: 600;
}

.quick-stat-value.up {
  color: var(--accent-success);
}

.quick-stat-value.down {
  color: var(--accent-danger);
}

/* Panel Layouts */
.panel {
  display: none;
  flex-direction: column;
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  height: calc(100vh - var(--header-height));
  animation: fadeIn 0.4s ease-out;
}

.panel.active {
  display: flex;
}

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(12px);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: 0 12px 35px -12px rgba(0, 0, 0, 0.6);
}

.card-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* Stat Cards Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
}

.stat-card.primary::before {
  background: linear-gradient(90deg, var(--accent-primary), #818cf8);
}

.stat-card.success::before {
  background: linear-gradient(90deg, var(--accent-success), #34d399);
}

.stat-card.danger::before {
  background: linear-gradient(90deg, var(--accent-danger), #fb7185);
}

.stat-card.warning::before {
  background: linear-gradient(90deg, var(--accent-warning), #fbbf24);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}

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

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

/* List details */
.holding-list, .transaction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: var(--transition-smooth);
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
  transform: translateX(4px);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ticker-badge {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 60px;
  text-align: center;
}

.item-details {
  display: flex;
  flex-direction: column;
}

.item-title {
  font-size: 14px;
  font-weight: 600;
}

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

.item-right {
  text-align: right;
}

.item-val {
  font-size: 14px;
  font-weight: 600;
}

.item-pct {
  font-size: 12px;
  font-weight: 500;
}

.item-pct.up {
  color: var(--accent-success);
}

.item-pct.down {
  color: var(--accent-danger);
}

/* AI Agent Panel */
#agent-panel.panel {
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

.ai-layout {
  display: grid;
  grid-template-columns: 2fr 1.1fr;
  gap: 24px;
  height: 100%;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 500px;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.3);
  border-radius: 12px;
  margin-bottom: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.agent {
  align-self: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.message.user .avatar {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.message.agent .avatar {
  background: linear-gradient(135deg, var(--accent-primary), #818cf8);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.message.user .message-bubble {
  background: var(--accent-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.agent .message-bubble {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

/* Chat bubble styling for code blocks or advice highlights */
.message-bubble ul, .message-bubble ol {
  margin-left: 20px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble p {
  margin-bottom: 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* Elegant responsive tables inside agent messages */
.message-bubble .table-container {
  width: 100%;
  overflow-x: auto;
  margin: 14px 0;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-bubble table.agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.message-bubble table.agent-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.message-bubble table.agent-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  white-space: nowrap;
}

.message-bubble table.agent-table tr:last-child td {
  border-bottom: none;
}

.message-bubble table.agent-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
}

.chat-input {
  flex-grow: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  transition: var(--transition-smooth);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-send {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.55);
}

.btn-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.btn-stop {
  background: linear-gradient(135deg, var(--accent-danger), #e11d48);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: none; /* hidden by default */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

.btn-stop:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.55);
}

.btn-stop svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.suggestion-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.suggestion-chip:hover {
  background: var(--accent-primary-glow);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

/* Agent Insights Side panel */
.agent-insights {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: 100%;
  padding-right: 4px;
}

.health-score-ring {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 16px auto;
}

.health-score-ring svg {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: var(--accent-success);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-in-out;
}

.health-score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-num {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
}

.score-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.insight-metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.insight-metric-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.metric-card-val {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-card-val.success { color: var(--accent-success); }
.metric-card-val.warning { color: var(--accent-warning); }
.metric-card-val.danger { color: var(--accent-danger); }

.metric-card-lbl {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Market Watch Panel */
.market-grid {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 24px;
  flex-grow: 1;
}

.market-search {
  position: relative;
  margin-bottom: 16px;
}

.market-search input {
  width: 100%;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  padding: 12px 16px 12px 40px;
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-main);
  font-size: 14px;
}

.market-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2.5;
}

.stock-tickers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 500px;
}

.stock-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.stock-card:hover, .stock-card.active {
  background: var(--accent-primary-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

.stock-card.active {
  box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.1);
}

/* Chart Card & Timeline selector */
.chart-controls {
  display: flex;
  gap: 8px;
}

.btn-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

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

.chart-wrapper {
  position: relative;
  height: 320px;
  margin-top: 16px;
}

/* Trade Modal / Section styling */
.trade-actions-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.btn-action {
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-main);
  transition: var(--transition-smooth);
  font-size: 14px;
}

.btn-action.buy {
  background: var(--accent-success);
  color: var(--bg-primary);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-action.buy:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-action.sell {
  background: var(--accent-danger);
  color: #fff;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

.btn-action.sell:hover {
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.5);
  transform: translateY(-1px);
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

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

.form-group input, .form-group select {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 10px;
  color: white;
  font-family: var(--font-main);
  font-size: 14px;
  transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Trading Desk layout */
.trading-layout {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 24px;
}

/* Settings styling */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.btn-danger {
  background: var(--accent-danger);
  border: none;
  color: white;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-main);
  transition: var(--transition-smooth);
  margin-top: 10px;
}

.btn-danger:hover {
  background: #e11d48;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

.btn-save {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-main);
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-save:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Responsiveness */
@media (max-width: 1024px) {
  .dashboard-grid, .ai-layout, .market-grid, .trading-layout {
    grid-template-columns: 1fr !important;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  /* Fix container height and prevent body scroll double scrollbars */
  .app-container {
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
  }

  /* Bottom Navigation Sidebar */
  aside.sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 64px !important;
    flex-direction: row !important;
    border-right: none !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 0 8px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    z-index: 9999 !important;
    justify-content: space-around !important;
    align-items: center !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
  }

  .logo-container, .sidebar-footer, .nav-item#nav-audio-tour {
    display: none !important;
  }

  .nav-menu {
    flex-direction: row !important;
    width: 100% !important;
    height: 100% !important;
    justify-content: space-around !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  .nav-item {
    width: auto !important;
    flex: 1 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: 100% !important;
  }

  .nav-link {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px 4px !important;
    gap: 4px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .nav-link svg {
    width: 22px !important;
    height: 22px !important;
  }

  .nav-item.active .nav-link {
    color: var(--accent-primary) !important;
  }
  
  .nav-item.active .nav-link svg {
    color: var(--accent-primary) !important;
  }

  /* Main Content adjustments */
  main.main-content {
    height: calc(100vh - 64px) !important;
    max-height: calc(100vh - 64px) !important;
    margin-bottom: 0 !important;
    overflow: hidden !important;
  }

  header.top-header {
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 16px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
  }

  .portfolio-quick-stats {
    display: none !important; /* Hide stats in header on mobile */
  }

  /* Panel Scroll Area */
  .panel {
    height: calc(100vh - 56px - 64px) !important;
    max-height: calc(100vh - 56px - 64px) !important;
    overflow-y: auto !important;
    padding: 16px !important;
    flex-grow: 1 !important;
  }

  .panel.active {
    display: flex !important;
  }

  /* Special Chat layouts on Mobile */
  #agent-panel.panel {
    height: calc(100vh - 120px) !important;
    max-height: calc(100vh - 120px) !important;
    overflow-y: auto !important; /* scroll between chat and insights */
  }

  .ai-layout {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    gap: 16px !important;
  }

  .chat-container {
    height: 480px !important; /* Fixed height for chat container on mobile */
    min-height: auto !important;
    flex-shrink: 0 !important;
  }

  .chat-messages {
    flex-grow: 1 !important;
    overflow-y: auto !important;
  }

  .agent-insights {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: 100% !important;
  }

  /* Stack stats row to 2 columns */
  .stats-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr !important;
  }
  .portfolio-quick-stats {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .quick-stat {
    align-items: flex-start !important;
  }
}

/* --- BROKERAGE SYNC HUB TABS & MODALS --- */

/* Tabs Navigation for Sync Hub */
.sync-tab-controls {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.sync-tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

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

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

.sync-tab-content {
  display: none;
}

.sync-tab-content.active {
  display: block;
}

/* Warning Banner for Unresolved Assets */
#unresolved-warning-banner {
  animation: fadeIn 0.4s ease-out;
}

#unresolved-warning-banner button:hover {
  background: #f59e0b !important;
  transform: translateY(-1px);
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: modalFadeIn 0.3s ease-out;
}

/* Modal Container */
.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-close-modal:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Reconcile Holdings Table Inside Modal */
.reconcile-table {
  width: 100%;
  border-collapse: collapse;
}

.reconcile-table th, .reconcile-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.reconcile-table input {
  background: rgba(9, 13, 22, 0.5);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 6px;
  color: white;
  font-family: var(--font-main);
  font-size: 13px;
  width: 100%;
  transition: all 0.2s;
}

.reconcile-table input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(9, 13, 22, 0.8);
}

.btn-delete-row {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: var(--accent-danger);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-row:hover {
  background: var(--accent-danger);
  color: white;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

/* Animations for Modals */
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Audio Guided Tour Highlight */
.tour-highlight {
  outline: 3px solid var(--accent-primary) !important;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.8) !important;
  transition: all 0.4s ease-in-out;
  z-index: 9999;
  position: relative;
}

/* Autocomplete Combobox styling */
.autocomplete-item {
  transition: background 0.2s ease-in-out;
}
.autocomplete-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}
.autocomplete-item.search-schwab-item:hover {
  background: rgba(99, 102, 241, 0.18) !important;
}

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

