:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.6);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --primary: #a855f7;
  --primary-glow: rgba(168, 85, 247, 0.4);
  --accent-blue: #3b82f6;
  
  --grade-s: #f59e0b; /* Gold */
  --grade-a: #10b981; /* Emerald */
  --grade-b: #22c55e; /* Green */
  --grade-c: #3b82f6; /* Blue */
  --grade-d: #f97316; /* Orange */
  --grade-f: #ef4444; /* Red */
  
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --font-main: 'Inter', 'Noto Sans KR', sans-serif;
  --font-logo: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding-bottom: 60px;
}

/* Background Lighting Glows */
.bg-glow {
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

.bg-glow-purple {
  top: -10%;
  left: -10%;
  background: var(--primary);
}

.bg-glow-blue {
  bottom: -10%;
  right: -10%;
  background: var(--accent-blue);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Glassmorphism Panel Common */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
}

/* App Header */
.app-header {
  padding: 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

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

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 30px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(-3px);
}

.logo-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-logo);
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: 0 0 15px var(--primary-glow);
}

.app-title {
  font-family: var(--font-logo);
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

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

.badge-market {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #e9d5ff;
  padding: 8px 16px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 13px;
}

/* Search Section */
.search-section {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.search-box-wrapper {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.input-group {
  flex: 1;
  min-width: 280px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

#stock-search-input {
  width: 100%;
  padding: 16px 20px 16px 52px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
  font-size: 15px;
  outline: none;
  transition: all 0.3s ease;
}

#stock-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.btn-primary {
  padding: 16px 32px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
  background: linear-gradient(135deg, #b55fe6, #9061f9);
}

.quick-suggest {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.suggest-label {
  color: var(--text-muted);
  font-weight: 500;
}

.suggest-link {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggest-link:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
  color: white;
  transform: translateY(-1px);
}

/* Loading Card */
.loading-card {
  padding: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}

.spinner-wrapper {
  width: 60px;
  height: 60px;
  position: relative;
}

.double-bounce1, .double-bounce2 {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--primary);
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
  animation-delay: -1.0s;
  background-color: var(--accent-blue);
}

@keyframes sk-bounce {
  0%, 100% { 
    transform: scale(0.0);
  } 50% { 
    transform: scale(1.0);
  }
}

.loading-text-wrapper h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.loading-text-wrapper p {
  font-size: 14px;
  color: var(--text-muted);
}

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

.grid-span-all {
  grid-column: span 2;
}

.column-left, .column-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Common Card */
.card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.card-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: -10px;
}

/* Profile Card */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 15px;
}

.company-market {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

.company-name {
  font-size: 26px;
  font-weight: 700;
  margin: 6px 0 2px 0;
}

.company-ticker {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-logo);
}

.price-wrapper {
  text-align: right;
}

.current-price {
  display: block;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-logo);
}

.price-change {
  font-size: 13.5px;
  font-weight: 600;
}

.price-up {
  color: #ef4444;
}

.price-down {
  color: #3b82f6;
}

.price-even {
  color: var(--text-muted);
}

.profile-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  padding: 15px 0;
  border-top: 1px solid var(--border-glass);
  border-bottom: 1px solid var(--border-glass);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.meta-value {
  font-size: 15px;
  font-weight: 600;
}

.company-desc h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.company-desc p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Grade Circle & Radar Card */
.grade-main-row {
  display: flex;
  align-items: center;
  gap: 24px;
  background: rgba(255, 255, 255, 0.02);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.grade-circle-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.8s ease;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.grade-letter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-logo);
  font-weight: 800;
  font-size: 42px;
}

.recommendation-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.badge-strong-buy {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fef08a;
}

.badge-buy {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.badge-hold {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}

.badge-sell {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

.grade-score-text {
  font-size: 15px;
  color: var(--text-secondary);
}

.grade-score-text strong {
  font-size: 20px;
  color: white;
  font-family: var(--font-logo);
}

.grade-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

.chart-container {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

/* Word Cloud Card */
.wordcloud-wrapper {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#wordcloud-canvas {
  width: 100%;
  max-width: 480px;
  height: 280px;
}

/* News List Card */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-link {
  font-size: 13px;
  color: #c084fc;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s ease;
}

.btn-link:hover {
  color: white;
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 330px;
  overflow-y: auto;
  padding-right: 5px;
}

/* Custom scrollbar for news */
.news-list::-webkit-scrollbar {
  width: 5px;
}
.news-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.news-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.news-item:hover {
  background: rgba(168, 85, 247, 0.06);
  border-color: rgba(168, 85, 247, 0.2);
  transform: translateY(-1px);
}

.news-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.news-source {
  color: #c084fc;
  font-weight: 600;
}

/* Financial Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.financial-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13.5px;
}

.financial-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.financial-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.financial-table th:first-child,
.financial-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: white;
}

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

/* Algorithm Checklist Grid */
.algorithm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.algo-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.algo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 10px;
}

.algo-title {
  font-size: 14px;
  font-weight: 700;
  color: white;
}

.algo-score {
  font-family: var(--font-logo);
  font-size: 16px;
  font-weight: 800;
  color: var(--grade-s);
}

.algo-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.check-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
}

.check-list li {
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.check-list li .label {
  color: var(--text-secondary);
  line-height: 1.3;
}

.check-list li .value {
  font-family: var(--font-logo);
  font-weight: 600;
  white-space: nowrap;
}

.check-list li i {
  font-size: 13px;
}

.check-list li.pass {
  color: var(--grade-a);
}

.check-list li.fail {
  color: var(--text-muted);
}

.check-list li.pass .label {
  color: var(--text-primary);
}

.algo-extra-info {
  margin-top: 10px;
  font-size: 11.5px;
  color: #a855f7;
  background: rgba(168, 85, 247, 0.08);
  padding: 8px;
  border-radius: 6px;
  line-height: 1.4;
  border: 1px dashed rgba(168, 85, 247, 0.2);
}

/* Responsive Rules */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .grid-span-all {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 20px;
  }
  
  .app-title {
    font-size: 20px;
  }
  
  .search-section {
    padding: 20px;
  }
  
  .btn-primary {
    width: 100%;
    justify-content: center;
  }
  
  .profile-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .price-wrapper {
    text-align: left;
  }
  
  .grade-main-row {
    flex-direction: column;
    text-align: center;
  }
}
