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

:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #06b6d4; /* Cyan */
  --accent-danger: #f43f5e; /* Rose */
  --accent-warning: #f59e0b; /* Amber */
  --accent-success: #10b981; /* Emerald */

  --gradient-card: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.9) 100%);
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --gradient-danger: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --radius: 12px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  padding: 24px;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 24px 28px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.app-title {
  flex: 1;
}

.lang-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}

.lang-btn.active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.app-title h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.6;
}

.app-subtitle p {
  margin-bottom: 8px;
}

.app-subtitle p:last-child {
  margin-bottom: 0;
}

.app-subtitle a {
  color: var(--accent-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
  font-weight: 500;
}

.app-subtitle a:hover {
  color: #38bdf8;
}

.hcmc-warning-box {
  margin-top: 12px;
  padding: 14px 18px;
  background: rgba(244, 63, 94, 0.08);
  border-left: 4px solid var(--accent-danger);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-main);
  line-height: 1.6;
}

.hcmc-warning-box .warning-title {
  font-weight: 700;
  color: var(--accent-danger);
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Control Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.filter-select, .filter-input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

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

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Level 1: KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
}

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);

}

.kpi-value.danger { color: var(--accent-danger); }
.kpi-value.warning { color: var(--accent-warning); }
.kpi-value.success { color: var(--accent-success); }
.kpi-value.brand { color: var(--accent-secondary); }

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.combined-chart-card {
  height: 480px;
  margin-bottom: 28px;
}

.combined-chart-body {
  display: flex;
  flex: 1;
  gap: 20px;
  min-height: 0;
  align-items: stretch;
}

.image-wrapper {
  width: 260px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.advisor-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.split-grid .quantile-card {
  margin-bottom: 0;
}

.split-grid .chart-card {
  height: 100%;
  min-height: 340px;
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  height: 340px;
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  position: relative;
}

/* 5-Quantile Distribution Styling */
.quantile-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.quantile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.quantile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.4);
  transition: background 0.2s ease;
}

.quantile-row:hover {
  background: rgba(51, 65, 85, 0.5);
}

.quantile-row.median-row {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  font-weight: 700;
}

.quantile-name {
  width: 140px;
  font-weight: 600;
  color: var(--text-muted);
}

.quantile-bar-bg {
  flex: 1;
  height: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.quantile-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s ease;
}

.quantile-val {
  width: 120px;
  text-align: right;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

/* Data Table Container */
.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 11px;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* Level 4: Position Lifecycles Grid */
.position-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.position-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.position-card:hover {
  border-color: var(--border-highlight);
}

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

.position-sym {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-options { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.badge-stocks { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-futures { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.position-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
  background: rgba(15, 23, 42, 0.5);
  padding: 12px;
  border-radius: 8px;
}

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

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
}

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

.btn-inspect {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-inspect:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #ffffff;
}

.raw-trades-table {
  margin-top: 14px;
  display: none;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
}

.raw-trades-table.active {
  display: block;
}
