/* Root Variables & Design System */
:root {
  --bg-dark: #0B0F19;
  --bg-card: rgba(18, 26, 44, 0.75);
  --bg-card-hover: rgba(24, 35, 58, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  /* MDRX Brand Accent (Teal / Cyan) */
  --mdrx-primary: #06B6D4;
  --mdrx-glow: rgba(6, 182, 212, 0.25);
  --mdrx-border: rgba(6, 182, 212, 0.4);

  /* TOST Brand Accent (Amber / Coral) */
  --tost-primary: #F97316;
  --tost-glow: rgba(249, 115, 22, 0.25);
  --tost-border: rgba(249, 115, 22, 0.4);

  /* Financial Indicators */
  --positive: #10B981;
  --positive-bg: rgba(16, 185, 129, 0.12);
  --positive-border: rgba(16, 185, 129, 0.3);

  --negative: #EF4444;
  --negative-bg: rgba(239, 68, 68, 0.12);
  --negative-border: rgba(239, 68, 68, 0.3);

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow-mdrx: 0 0 25px rgba(6, 182, 212, 0.15);
  --shadow-glow-tost: 0 0 25px rgba(249, 115, 22, 0.15);
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 20% 10%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(249, 115, 22, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.app-container {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* Header Styling */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  padding: 2rem 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-main);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--positive-border);
  color: var(--positive);
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.dashboard-title {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #FFFFFF 0%, #CBD5E1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dashboard-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 400;
  margin-top: 0.25rem;
}

.header-metadata {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.meta-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
}

.meta-icon {
  color: var(--mdrx-primary);
  font-size: 1.1rem;
}

.meta-info {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.mdrx-theme::before {
  background: linear-gradient(90deg, var(--mdrx-primary), #38BDF8);
}

.tost-theme::before {
  background: linear-gradient(90deg, var(--tost-primary), #FBBF24);
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-main);
}

.mdrx-theme:hover {
  border-color: var(--mdrx-border);
  box-shadow: var(--shadow-glow-mdrx);
}

.tost-theme:hover {
  border-color: var(--tost-border);
  box-shadow: var(--shadow-glow-tost);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stock-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Ticker Badge Links */
.ticker-badge {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.link-icon {
  font-size: 0.75rem;
  opacity: 0.7;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ticker-badge:hover .link-icon {
  transform: translate(2px, -2px);
  opacity: 1;
}

.mdrx-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--mdrx-primary);
  border: 1px solid var(--mdrx-border);
}

.mdrx-badge:hover {
  background: rgba(6, 182, 212, 0.3);
  box-shadow: 0 0 12px var(--mdrx-glow);
}

.tost-badge {
  background: rgba(249, 115, 22, 0.15);
  color: var(--tost-primary);
  border: 1px solid var(--tost-border);
}

.tost-badge:hover {
  background: rgba(249, 115, 22, 0.3);
  box-shadow: 0 0 12px var(--tost-glow);
}

.company-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.stock-tags {
  font-size: 0.775rem;
  color: var(--text-muted);
  display: block;
}

.trend-pill {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.trend-pill.positive {
  background: var(--positive-bg);
  color: var(--positive);
  border: 1px solid var(--positive-border);
}

.trend-pill.negative {
  background: var(--negative-bg);
  color: var(--negative);
  border: 1px solid var(--negative-border);
}

.price-display {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.main-price {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  color: #FFFFFF;
}

.return-percentage {
  font-size: 1.15rem;
  font-weight: 700;
}

.return-percentage.positive { color: var(--positive); }
.return-percentage.negative { color: var(--negative); }

.kpi-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.metric-value {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

/* Charts Section */
.charts-section, .summary-section, .table-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #FFFFFF;
}

.section-title i {
  color: var(--mdrx-primary);
}

.chart-legend {
  display: flex;
  gap: 1.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.legend-item:hover {
  opacity: 0.85;
}

.legend-ext {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.mdrx-legend .color-dot { background-color: var(--mdrx-primary); box-shadow: 0 0 8px var(--mdrx-primary); }
.tost-legend .color-dot { background-color: var(--tost-primary); box-shadow: 0 0 8px var(--tost-primary); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1.75rem;
}

@media (max-width: 1100px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chart-card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.chart-subtitle {
  font-size: 0.825rem;
  color: var(--text-dim);
}

.canvas-container {
  position: relative;
  height: 320px;
  width: 100%;
}

/* Executive Quarterly Summary */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.75rem;
}

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

.summary-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mdrx-summary-card { border-left: 4px solid var(--mdrx-primary); }
.tost-summary-card { border-left: 4px solid var(--tost-primary); }

.summary-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ticker-chip {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ticker-chip:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.mdrx-chip { background: rgba(6, 182, 212, 0.2); color: var(--mdrx-primary); }
.tost-chip { background: rgba(249, 115, 22, 0.2); color: var(--tost-primary); }

.summary-card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.trajectory-tag {
  font-size: 0.775rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-highlight);
  color: #38BDF8;
}

.summary-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Data Table Styling */
.table-header-flex {
  align-items: flex-end;
}

.table-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
}

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

.search-box i {
  position: absolute;
  left: 1rem;
  color: var(--text-dim);
}

.search-box input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  width: 260px;
  transition: all 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--mdrx-primary);
  background: rgba(255, 255, 255, 0.08);
}

.table-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-height: 440px;
  overflow-y: auto;
  box-shadow: var(--shadow-main);
}

/* Custom Scrollbar for table */
.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.table-wrapper::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-highlight);
  border-radius: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #111827;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
}

.data-table td {
  padding: 0.9rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.change-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
}

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

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

.loading-cell {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem !important;
}

/* Footer Styling */
.dashboard-footer {
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 2rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer-subtext {
  font-size: 0.775rem;
  margin-top: 0.35rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  body { padding: 1rem 0.75rem; }
  .dashboard-header { padding: 1.5rem; }
  .dashboard-title { font-size: 1.75rem; }
  .kpi-metrics-grid { grid-template-columns: 1fr; }
  .canvas-container { height: 260px; }
  .search-box input { width: 100%; }
  .table-header-flex { flex-direction: column; align-items: stretch; }
}
