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

:root {
  /* Color Palette */
  --bg-dark: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-sidebar: rgba(13, 18, 30, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Brand/Status Accents */
  --accent-cyan: #06b6d4;
  /* Foundry, advanced lithography */
  --accent-violet: #8b5cf6;
  /* GPU, AI logic, ASIC */
  --accent-emerald: #10b981;
  /* Memory (DRAM, NAND, HBM) */
  --accent-amber: #f59e0b;
  /* Equipment & Automation */
  --accent-rose: #f43f5e;
  /* Materials & Packaging Substrates */
  --accent-pink: #ec4899;
  /* Star tech, New categories */

  --glow-cyan: rgba(6, 182, 212, 0.15);
  --glow-violet: rgba(139, 92, 246, 0.15);
  --glow-emerald: rgba(16, 185, 129, 0.15);

  /* UI Constants */
  --sidebar-width: 300px;
  --header-height: 80px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --glass-blur: blur(12px);
}

/* Base Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

body {
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  box-shadow: var(--box-shadow);
}

/* Main Layout */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styling */
aside {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  overflow-y: auto;
  backdrop-filter: var(--glass-blur);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.logo-container svg {
  width: 32px;
  height: 32px;
  fill: var(--accent-cyan);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, #fff 30%, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.search-box {
  position: relative;
  margin-bottom: 24px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
}

.filter-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: block;
  font-weight: 600;
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.country-checkbox {
  display: none;
}

.country-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.country-label:hover {
  background: rgba(255, 255, 255, 0.06);
}

.country-checkbox:checked+.country-label {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--accent-cyan);
  color: var(--text-primary);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.1);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  border-left: 3px solid var(--accent-cyan);
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.08) 0%, transparent 100%);
  padding-left: 11px;
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Main Content Area */
main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px;
  max-width: 1400px;
  width: calc(100% - var(--sidebar-width));
}

/* Top Header & Market Alert */
header {
  margin-bottom: 32px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 20px;
}

.header-title-area h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ffffff 50%, rgba(255, 255, 255, 0.6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title-area p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.date-badge span {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* Volatility Alert Baner */
.market-alert-banner {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.1) 0%, rgba(244, 63, 94, 0.03) 100%);
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 16px 20px;
  border-radius: var(--border-radius-md);
  margin-bottom: 30px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 4px 20px rgba(244, 63, 94, 0.05);
}

.alert-icon {
  background: rgba(244, 63, 94, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.alert-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--accent-rose);
}

.alert-content h4 {
  color: var(--accent-rose);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.alert-content p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Big 6 Stock Ticker Grid */
.big-six-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.big-six-card {
  padding: 16px;
  border-radius: var(--border-radius-md);
  transition: transform var(--transition-normal), border-color var(--transition-fast);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

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

.big-six-card.nvda::before {
  background-color: var(--accent-violet);
}

.big-six-card.tsmc::before {
  background-color: var(--accent-cyan);
}

.big-six-card.broadcom::before {
  background-color: var(--accent-violet);
}

.big-six-card.samsung::before {
  background-color: var(--accent-emerald);
}

.big-six-card.hynix::before {
  background-color: var(--accent-emerald);
}

.big-six-card.micron::before {
  background-color: var(--accent-emerald);
}

.big-six-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-ticker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ticker-name {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.ticker-flag {
  font-size: 0.95rem;
}

.card-company-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.card-cap-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.1;
}

.card-cap-change {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}

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

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

/* Tab Content Styling */
.view-panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dashboard Summary Cards Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

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

.trends-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.trend-card {
  padding: 20px;
  border-radius: var(--border-radius-md);
  border-left: 4px solid var(--accent-cyan);
  transition: transform var(--transition-fast);
}

.trend-card:hover {
  transform: translateX(4px);
}

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

.trend-num {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.trend-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.trend-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Ecosystem Visual Map */
.ecosystem-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ecosystem-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.ecosystem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.eco-card {
  border-radius: var(--border-radius-md);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition-normal);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.eco-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  transform: translateY(-4px);
}

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

.eco-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.eco-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.eco-badge.memory {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.eco-badge.system {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-violet);
}

.eco-badge.foundry {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.eco-badge.packaging {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.eco-badge.equipment {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.eco-badge.materials {
  background: rgba(236, 72, 153, 0.1);
  color: var(--accent-pink);
}

.eco-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.eco-company-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-chip {
  font-size: 0.75rem;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* Database Table View */
.db-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.db-stats {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th,
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  user-select: none;
}

tr {
  transition: background-color var(--transition-fast);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.company-cell {
  display: flex;
  flex-direction: column;
}

.company-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-ticker {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.country-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.country-badge.kr {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.country-badge.us {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-violet);
}

.country-badge.tw {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
}

.country-badge.jp {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

.country-badge.eu {
  background: rgba(236, 72, 153, 0.1);
  color: var(--accent-pink);
}

.country-badge.cn {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.cap-badge {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

.desc-cell {
  color: var(--text-secondary);
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Insight Panels */
.insight-card {
  padding: 24px;
  border-radius: var(--border-radius-lg);
  margin-bottom: 24px;
  line-height: 1.65;
}

.insight-card h3 {
  font-size: 1.35rem;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.insight-card p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.insight-card ul {
  list-style-position: inside;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

/* Floating Modal / Details Side Drawer */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease;
}

.modal-container {
  width: 90%;
  max-width: 600px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

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

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

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

.close-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.detail-value.cap {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  aside {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  aside.open {
    transform: translateX(0);
  }

  main {
    margin-left: 0;
    width: 100%;
    padding: 20px;
  }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .big-six-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}