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

:root {
  --background: hsl(220 20% 6%);
  --foreground: hsl(210 20% 92%);
  --card: hsl(220 18% 10%);
  --card-soft: hsl(220 16% 13%);
  --border: hsl(220 14% 18%);
  --muted: hsl(220 14% 14%);
  --muted-foreground: hsl(215 12% 66%);
  --primary: hsl(199 100% 50%);
  --signal-buy: hsl(145 100% 39%);
  --signal-hold: hsl(40 100% 50%);
  --signal-sell: hsl(348 100% 55%);
  --radius: 12px;
}

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

html, body {
  background:
    radial-gradient(1200px 500px at -10% -20%, rgba(0, 180, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(30, 255, 166, 0.08), transparent 60%),
    var(--background);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  min-height: 100vh;
}

p, span, label { color: var(--foreground); }
.mono { font-family: "JetBrains Mono", monospace; }

.app-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1rem 2.5rem;
}

/* ── Login ─────────────────────────────────────────────────────────── */

.login-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-card {
  border-radius: var(--radius);
  border: 1px solid hsl(220 14% 18% / 0.65);
  background: hsl(220 18% 10% / 0.72);
  backdrop-filter: blur(20px);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.login-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus { border-color: var(--primary); }

.login-input::placeholder { color: var(--muted-foreground); }

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
  border-radius: 10px;
  border: 1px solid hsl(220 14% 18% / 0.85);
  background: hsl(220 14% 14% / 0.45);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:hover {
  border-color: hsl(199 100% 50% / 0.7);
  color: hsl(199 100% 60%);
}

.btn-primary {
  background: hsl(199 100% 50% / 0.2);
  border-color: hsl(199 100% 50% / 0.4);
  color: var(--foreground);
  min-height: 2.5rem;
}

.btn-primary:hover {
  background: hsl(199 100% 50% / 0.35);
}

.logout-btn {
  font-size: 0.72rem;
  padding: 0.3rem 0.7rem;
  margin-left: auto;
}

/* ── Select ───────────────────────────────────────────────────────── */

.select-input {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239FA8B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

.select-input:focus { border-color: var(--primary); }

/* ── Spinner ──────────────────────────────────────────────────────── */

.spinner {
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.88rem;
  padding: 3rem 1rem;
}

/* ── Header ───────────────────────────────────────────────────────── */

.sticky-header {
  position: sticky;
  top: 0.3rem;
  z-index: 40;
  border: 1px solid hsl(220 14% 18% / 0.6);
  background: hsl(220 18% 10% / 0.65);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  margin-bottom: 1rem;
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

.header-inner {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  text-align: center;
}

.brand-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #081622;
  background: linear-gradient(135deg, hsl(199 100% 50%), hsl(145 100% 39%));
  flex-shrink: 0;
}

.brand-title { margin: 0; font-size: 1.04rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-subtitle { margin: 0.1rem 0 0; color: var(--muted-foreground); font-size: 0.76rem; }

.market-status { display: flex; align-items: center; gap: 0.45rem; }

.pulse-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 999px;
  background: var(--signal-buy);
  box-shadow: 0 0 0 0 rgba(0, 201, 107, 0.7);
  animation: pulse-glow 2s ease-in-out infinite;
}

.pulse-dot.dot-closed { background: var(--signal-sell); box-shadow: none; animation: none; }

.status-text { font-family: "JetBrains Mono", monospace; font-size: 0.75rem; color: var(--muted-foreground); }

.data-source {
  font-family: "JetBrains Mono", monospace; font-size: 0.6rem;
  color: hsl(199 100% 58%); background: hsl(199 100% 50% / 0.12);
  padding: 0.12rem 0.4rem; border-radius: 999px; white-space: nowrap;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  border: 1px solid hsl(220 14% 18% / 0.7);
  border-radius: 12px; padding: 0.3rem;
  background: hsl(220 18% 10% / 0.65);
  margin-bottom: 1.1rem;
  max-width: 980px; margin-left: auto; margin-right: auto;
}

.tab-btn {
  border-radius: 10px; padding: 0.38rem 0.8rem;
  color: var(--muted-foreground); font-weight: 600; font-size: 0.88rem;
  border: none; background: transparent; cursor: pointer;
  font-family: "Inter", sans-serif; transition: all 0.15s;
}

.tab-btn:hover { color: var(--foreground); }
.tab-btn.active { background: hsl(199 100% 50% / 0.2); color: var(--foreground); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Sections ─────────────────────────────────────────────────────── */

.section-title-row { margin-bottom: 0.75rem; }
.section-title { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.section-subtitle { margin: 0.25rem 0 0; color: var(--muted-foreground); font-size: 0.9rem; }

/* ── Glass Cards ──────────────────────────────────────────────────── */

.glass-card {
  border-radius: var(--radius);
  border: 1px solid hsl(220 14% 18% / 0.65);
  background: hsl(220 18% 10% / 0.72);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 hsl(220 20% 4% / 0.5), 0 12px 24px hsl(220 40% 3% / 0.35);
  padding: 1rem; margin-bottom: 0.75rem;
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.85rem; flex-wrap: wrap; }
.card-main { flex: 1 1 18rem; }

.signal-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.01em; padding: 0.2rem 0.55rem; margin-bottom: 0.45rem;
}
.signal-pill .signal-dot { width: 0.42rem; height: 0.42rem; border-radius: 999px; background: currentColor; }
.signal-buy { color: hsl(145 100% 39%); background: hsl(145 100% 39% / 0.15); }
.signal-hold { color: hsl(40 100% 50%); background: hsl(40 100% 50% / 0.15); }
.signal-sell { color: hsl(348 100% 55%); background: hsl(348 100% 55% / 0.15); }

.stock-ticker { margin: 0; font-family: "JetBrains Mono", monospace; font-size: 1.02rem; font-weight: 700; }
.stock-name { margin: 0.2rem 0 0; color: var(--muted-foreground); font-size: 0.85rem; }
.price-wrap { text-align: right; min-width: 12rem; }
.stock-price { margin: 0; font-size: 1.16rem; font-weight: 700; }
.stock-change { margin: 0.2rem 0 0; font-size: 0.85rem; font-weight: 700; }
.signal-buy-text { color: hsl(145 100% 39%); }
.signal-sell-text { color: hsl(348 100% 55%); }

.alert-strip {
  margin: -0.2rem 0 0.7rem;
  border: 1px solid hsl(40 100% 50% / 0.28); background: hsl(40 100% 50% / 0.12);
  border-radius: 10px; padding: 0.55rem 0.7rem;
  color: hsl(40 100% 58%); font-size: 0.8rem;
}

.metric-box {
  border-radius: 10px; border: 1px solid hsl(220 14% 18% / 0.75);
  background: hsl(220 14% 14% / 0.45); text-align: center;
  padding: 0.65rem; margin: 0.55rem 0;
}
.metric-box p { margin: 0; color: var(--muted-foreground); font-size: 0.72rem; }
.metric-box h4 { margin: 0.25rem 0 0; font-family: "JetBrains Mono", monospace; font-size: 0.9rem; font-weight: 600; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

.stock-description { color: var(--muted-foreground); font-size: 0.88rem; line-height: 1.45; margin: 0.25rem 0 0.1rem; }

.chart-label {
  margin: 0.55rem 0 0.2rem; color: var(--muted-foreground);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}

.chart-container { position: relative; }

.opportunity-badges { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.45rem; flex-wrap: wrap; }
.sector-pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  background: hsl(199 100% 50% / 0.16); color: hsl(199 100% 58%);
  font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.55rem;
}
.opportunity-reason { margin: 0.65rem 0 0; color: hsl(210 20% 88%); line-height: 1.45; font-size: 0.87rem; }

.empty-result {
  border: 1px dashed hsl(220 14% 18% / 0.8); background: hsl(220 14% 14% / 0.4);
  border-radius: 10px; padding: 0.6rem; text-align: center;
  color: var(--muted-foreground); font-size: 0.83rem;
}

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.summary-card {
  border-radius: 10px; border: 1px solid hsl(220 14% 18% / 0.75);
  background: hsl(220 14% 14% / 0.45); padding: 0.7rem 0.85rem;
}
.summary-label { margin: 0; color: var(--muted-foreground); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.summary-value { margin: 0.3rem 0 0; font-size: 1rem; font-weight: 700; }

/* ── Noticias ──────────────────────────────────────────────────────── */

.news-card {
  display: block; text-decoration: none; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 0.6rem; transition: border-color 0.2s, transform 0.2s;
}
.news-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.news-card-body { padding: 1rem; }
.news-ticker-badge {
  display: inline-block; font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem; font-weight: 600; color: var(--primary);
  background: hsl(199 100% 50% / 0.12); padding: 0.15rem 0.5rem;
  border-radius: 6px; margin-bottom: 0.4rem;
}
.news-title { font-size: 0.92rem; font-weight: 600; color: var(--foreground); margin: 0.3rem 0 0.5rem; line-height: 1.35; }
.news-meta { display: flex; gap: 1rem; font-size: 0.72rem; color: var(--muted-foreground); font-family: "JetBrains Mono", monospace; }

/* ── Top Acciones ──────────────────────────────────────────────────── */

.hero-stock-card {
  background: linear-gradient(135deg, hsl(220 18% 10%), hsl(199 40% 12%));
  border: 1px solid hsl(199 100% 50% / 0.3); border-radius: var(--radius);
  padding: 1.5rem; margin-bottom: 1.2rem; text-align: center;
}
.hero-stock-badge {
  display: inline-block; font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem; font-weight: 600; color: var(--signal-buy);
  background: hsl(145 100% 39% / 0.12); padding: 0.2rem 0.7rem;
  border-radius: 6px; margin-bottom: 0.6rem;
}
.hero-stock-ticker { font-family: "JetBrains Mono", monospace; font-size: 1.6rem; font-weight: 800; color: var(--foreground); margin: 0.2rem 0 0.1rem; }
.hero-stock-name { font-size: 0.88rem; color: var(--muted-foreground); margin: 0; }
.hero-stock-sector { font-size: 0.72rem; color: var(--primary); margin: 0.2rem 0 0.8rem; }
.hero-stock-price-row { display: flex; justify-content: center; align-items: baseline; gap: 0.8rem; }
.hero-stock-price { font-family: "JetBrains Mono", monospace; font-size: 1.8rem; font-weight: 700; color: var(--foreground); }
.hero-stock-change { font-family: "JetBrains Mono", monospace; font-size: 1.1rem; font-weight: 600; }

.top-section-label { font-size: 0.82rem; font-weight: 700; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }

/* ── Ranking Rows ──────────────────────────────────────────────────── */

.ranking-row {
  display: flex; align-items: center; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin-bottom: 0.35rem; gap: 0.7rem;
}
.ranking-pos { font-family: "JetBrains Mono", monospace; font-size: 0.82rem; font-weight: 800; color: var(--muted-foreground); min-width: 2rem; }
.ranking-pos.rank-gold { color: hsl(45 100% 55%); }
.ranking-pos.rank-silver { color: hsl(0 0% 75%); }
.ranking-pos.rank-bronze { color: hsl(25 60% 50%); }
.ranking-info { flex: 1; min-width: 0; }
.ranking-ticker { font-family: "JetBrains Mono", monospace; font-size: 0.8rem; font-weight: 700; color: var(--foreground); margin-right: 0.5rem; }
.ranking-name { font-size: 0.72rem; color: var(--muted-foreground); }
.ranking-right { display: flex; align-items: baseline; gap: 0.5rem; text-align: right; flex-shrink: 0; }
.ranking-price { font-family: "JetBrains Mono", monospace; font-size: 0.82rem; font-weight: 600; color: var(--foreground); }

/* ── Divisas ───────────────────────────────────────────────────────── */

.currency-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1rem; }

.currency-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 0;
}
.currency-card-main { border-color: hsl(199 100% 50% / 0.4); background: linear-gradient(135deg, hsl(220 18% 10%), hsl(199 40% 12%)); }
.currency-name { font-family: "JetBrains Mono", monospace; font-size: 0.95rem; font-weight: 700; color: var(--foreground); margin: 0 0 0.1rem; }
.currency-desc { font-size: 0.72rem; color: var(--muted-foreground); margin: 0 0 0.5rem; }
.currency-price-row { display: flex; align-items: baseline; gap: 0.7rem; }
.currency-price { font-family: "JetBrains Mono", monospace; font-size: 1.2rem; font-weight: 700; color: var(--foreground); }

/* ── Animations ────────────────────────────────────────────────────── */

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(0, 201, 107, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(0, 201, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 201, 107, 0); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fade-in-up 0.45s ease-out both; }

/* ── Responsive 768px ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-container { padding: 0 0.6rem 2rem; }
  .sticky-header { border-radius: 10px; margin-bottom: 0.7rem; }
  .header-inner { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.7rem; }
  .brand-title { font-size: 0.92rem; }
  .brand-subtitle { font-size: 0.68rem; }
  .status-text { font-size: 0.65rem; }
  .data-source { font-size: 0.52rem; }
  .section-title { font-size: 1.1rem; }
  .section-subtitle { font-size: 0.8rem; }
  .glass-card { padding: 0.75rem; margin-bottom: 0.6rem; border-radius: 10px; }
  .card-head { flex-direction: column; gap: 0.5rem; }
  .card-main { flex: 1 1 auto; min-width: 0; width: 100%; }
  .price-wrap { text-align: left; min-width: unset; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
  .stock-price { font-size: 1.05rem; }
  .stock-change { margin: 0; font-size: 0.78rem; }
  .stock-ticker { font-size: 0.92rem; }
  .stock-name { font-size: 0.78rem; }
  .signal-pill { font-size: 0.66rem; padding: 0.18rem 0.45rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 0.45rem; }
  .summary-label { font-size: 0.62rem; }
  .summary-value { font-size: 0.85rem; }
  .tab-bar { border-radius: 10px; padding: 0.25rem; gap: 0.25rem; margin-bottom: 0.8rem; }
  .tab-btn { padding: 0.32rem 0.6rem; font-size: 0.78rem; border-radius: 8px; }
  .currency-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Responsive 400px ──────────────────────────────────────────────── */

@media (max-width: 400px) {
  .app-container { padding: 0 0.4rem 1.5rem; }
  .header-inner { padding: 0.5rem 0.55rem; }
  .brand-icon { width: 1.7rem; height: 1.7rem; font-size: 0.62rem; border-radius: 8px; }
  .brand-title { font-size: 0.84rem; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 0.35rem; }
  .glass-card { padding: 0.6rem; }
  .stock-price { font-size: 0.95rem; }
  .hero-stock-card { padding: 1rem; }
  .hero-stock-price { font-size: 1.3rem; }
  .ranking-row { flex-wrap: wrap; gap: 0.3rem; padding: 0.5rem 0.6rem; }
  .ranking-right { width: 100%; justify-content: flex-end; }
  .currency-card { padding: 0.7rem; }
  .news-card-body { padding: 0.7rem; }
}
