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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

.app { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.logo { font-size: 1.4rem; font-weight: 700; color: #60a5fa; }

.search-bar { display: flex; gap: 8px; }
.search-bar input {
  background: #1e2330;
  border: 1px solid #2d3748;
  border-radius: 8px;
  color: #e2e8f0;
  padding: 8px 14px;
  font-size: 0.95rem;
  width: 260px;
  outline: none;
}
.search-bar input:focus { border-color: #60a5fa; }
.search-bar button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}
.search-bar button:hover { background: #1d4ed8; }

/* Market Overview */
.market-overview {
  background: #1e2330;
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.market-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.market-title { font-size: 1rem; color: #94a3b8; margin: 0; }
.update-time { font-size: 0.78rem; color: #475569; margin-left: 4px; }
.refresh-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #2d3748;
  border-radius: 6px;
  color: #64748b;
  width: 28px; height: 28px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.refresh-btn:hover { border-color: #60a5fa; color: #60a5fa; }
.refresh-btn.spinning { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.index-card {
  background: #151a26;
  border: 1px solid #2d3748;
  border-radius: 10px;
  padding: 14px 16px 10px;
  transition: border-color 0.2s;
}
.index-card:hover { border-color: #3d4f6b; }
.index-name { font-size: 0.78rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.index-price { font-size: 1.5rem; font-weight: 700; color: #f1f5f9; margin-bottom: 4px; }
.index-change { font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.index-change.positive { color: #34d399; }
.index-change.negative { color: #f87171; }
.index-change.neutral  { color: #94a3b8; }
.index-range { font-size: 0.75rem; color: #475569; margin-bottom: 8px; }
.sparkline { width: 100% !important; height: 40px !important; display: block; }
.index-card.loading .index-price,
.index-card.loading .index-change { color: #2d3748; }
.index-error { font-size: 0.78rem; color: #f87171; margin-top: 4px; }

/* Ticker buttons */
.ticker-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.ticker-btn {
  background: #1e2330;
  border: 1px solid #2d3748;
  border-radius: 8px;
  color: #94a3b8;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.ticker-btn:hover { border-color: #60a5fa; color: #60a5fa; }
.ticker-btn.active { background: #1d3a6e; border-color: #2563eb; color: #60a5fa; }

/* Card */
.card {
  background: #1e2330;
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 1rem; color: #94a3b8; margin-bottom: 14px; }

/* Company Card */
.company-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.company-header h2 { font-size: 1.5rem; font-weight: 700; }
.badge {
  display: inline-block;
  background: #2563eb22;
  color: #60a5fa;
  border: 1px solid #2563eb44;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 8px;
}
.badge-gray { background: #2d374844; color: #94a3b8; border-color: #2d3748; }

.price-block { text-align: right; }
.price { font-size: 2rem; font-weight: 700; display: block; }
.change { font-size: 0.95rem; font-weight: 600; }
.change.positive { color: #34d399; }
.change.negative { color: #f87171; }

.company-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.metric-label { font-size: 0.8rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 1.4rem; font-weight: 700; color: #f1f5f9; }

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

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left;
  padding: 10px 12px;
  color: #64748b;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #2d3748;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid #1a202c; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #252d3d; }

/* Utility */
.hidden { display: none !important; }
.loading {
  text-align: center;
  padding: 40px;
  color: #64748b;
  font-size: 1.1rem;
}
.error {
  background: #f8717122;
  border: 1px solid #f8717144;
  color: #f87171;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
