/* ==========================================================================
   VALUE RADAR PRO — DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
  /* Color Palette - HSL Tailored Dark Theme */
  --bg-base: hsl(222, 24%, 9%);
  --bg-card: hsl(222, 20%, 13%);
  --bg-card-hover: hsl(222, 20%, 16%);
  --bg-glass: rgba(22, 28, 42, 0.75);
  --border-subtle: hsl(222, 16%, 22%);
  --border-accent: hsl(210, 100%, 56%);

  /* Typography Colors */
  --text-primary: hsl(210, 30%, 98%);
  --text-secondary: hsl(215, 18%, 70%);
  --text-muted: hsl(215, 14%, 50%);

  /* Financial Indicators */
  --accent-blue: hsl(210, 100%, 56%);
  --accent-green: hsl(152, 76%, 45%);
  --accent-green-bg: hsla(152, 76%, 45%, 0.14);
  --accent-gold: hsl(42, 100%, 55%);
  --accent-gold-bg: hsla(42, 100%, 55%, 0.14);
  --accent-red: hsl(0, 84%, 60%);
  --accent-red-bg: hsla(0, 84%, 60%, 0.14);
  --accent-purple: hsl(270, 75%, 65%);
  --accent-purple-bg: hsla(270, 75%, 65%, 0.15);

  /* Elevation and Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.25);

  /* Fonts */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 32px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

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

.logo-icon {
  font-size: 32px;
  background: hsla(210, 100%, 56%, 0.15);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid hsla(210, 100%, 56%, 0.3);
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-pro {
  font-size: 11px;
  font-weight: 700;
  color: var(--bg-base);
  background: linear-gradient(135deg, var(--accent-gold), hsl(30, 100%, 50%));
  padding: 2px 8px;
  border-radius: 4px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

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

.metric-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
}

.metric-chip.highlight {
  border-color: hsla(152, 76%, 45%, 0.5);
  background: linear-gradient(180deg, var(--bg-card), hsla(152, 76%, 45%, 0.05));
}

.chip-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.chip-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-chip.highlight .chip-value {
  color: var(--accent-green);
}

.chip-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px hsla(210, 100%, 56%, 0.25);
}

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

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

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
.nav-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  color: #fff;
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-glow);
}

.badge-counter {
  background: var(--accent-green);
  color: var(--bg-base);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 12px;
}

/* ==========================================================================
   MAIN CONTENT & TABS
   ========================================================================== */
.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================================================
   STATS GRID (RADAR)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-card.highlight-green {
  border-color: hsla(152, 76%, 45%, 0.4);
  background: linear-gradient(180deg, var(--bg-card), hsla(152, 76%, 45%, 0.08));
}

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

.stat-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.stat-badge.info { background: hsla(210, 100%, 56%, 0.15); color: var(--accent-blue); }
.stat-badge.success { background: var(--accent-green-bg); color: var(--accent-green); }
.stat-badge.special { background: var(--accent-gold-bg); color: var(--accent-gold); }
.stat-badge.warning { background: var(--accent-red-bg); color: var(--accent-red); }

.stat-number {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-card.highlight-green .stat-number {
  color: var(--accent-green);
}

.stat-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   TABLE CONTROLS & SEARCH
   ========================================================================== */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  gap: 12px;
}

.search-icon {
  font-size: 16px;
  color: var(--text-muted);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filters-group {
  display: flex;
  gap: 12px;
}

.custom-select {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
}

.custom-select:focus {
  border-color: var(--accent-blue);
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background: hsl(222, 24%, 11%);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.ticker-box {
  display: flex;
  flex-direction: column;
}

.ticker-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.ticker-name {
  font-size: 12px;
  color: var(--text-secondary);
}

.sector-tag {
  display: inline-block;
  font-size: 11px;
  background: hsla(215, 14%, 50%, 0.15);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.moat-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Financial values */
.val-primary {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
}

.val-secondary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Discount and Scores */
.pill-discount {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.pill-discount.mega {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid hsla(152, 76%, 45%, 0.4);
}

.pill-discount.good {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.pill-discount.fair {
  background: var(--accent-gold-bg);
  color: var(--accent-gold);
}

.pill-discount.overpriced {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.score-badge {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 15px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.score-badge.tier-mega {
  background: linear-gradient(135deg, hsl(152, 76%, 40%), hsl(160, 80%, 30%));
  color: #fff;
  box-shadow: 0 0 10px hsla(152, 76%, 45%, 0.35);
}

.score-badge.tier-good {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid hsla(152, 76%, 45%, 0.4);
}

.score-badge.tier-fair {
  background: var(--accent-gold-bg);
  color: var(--accent-gold);
}

.score-badge.tier-poor {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-accent { color: var(--accent-green); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  border: none;
}

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

.btn.primary:hover {
  background: hsl(210, 100%, 62%);
  box-shadow: 0 0 14px hsla(210, 100%, 56%, 0.4);
}

.btn.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   PORTFOLIO TAB SPECIFIC
   ========================================================================== */
.portfolio-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.portfolio-stats-summary {
  display: flex;
  gap: 32px;
}

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

.p-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.p-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
}

.p-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.portfolio-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Sector Risk Progress Bars */
.sector-allocation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  margin-bottom: 20px;
}

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

.sector-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.sector-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.sector-status-badge.warning {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.sector-bar-wrapper {
  display: flex;
  gap: 8px;
  height: 12px;
  background: hsl(222, 24%, 9%);
  border-radius: 6px;
  overflow: hidden;
  padding: 2px;
}

.sector-bar-segment {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ==========================================================================
   ORDERS TAB BANNER & TABLE
   ========================================================================== */
.orders-guide-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, hsla(210, 100%, 56%, 0.1), hsla(152, 76%, 45%, 0.08));
  border: 1px solid hsla(210, 100%, 56%, 0.3);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.guide-icon {
  font-size: 36px;
}

.guide-text h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.guide-text p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-actions {
  margin-left: auto;
}

.order-action-pill {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  display: inline-block;
}

.order-action-pill.buy {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid hsla(152, 76%, 45%, 0.5);
}

.order-action-pill.trim {
  background: var(--accent-gold-bg);
  color: var(--accent-gold);
  border: 1px solid hsla(42, 100%, 55%, 0.5);
}

/* ==========================================================================
   MODAL WINDOWS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.2s ease forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.modal-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent-green);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 600;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease forwards;
}

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

.loading-cell, .empty-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}
