:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --verde: #16a34a;
  --rojo: #dc2626;
  --ambar: #d97706;
  --nav-h: 64px;
  --top-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #141c2e;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #243049;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  padding: 12px 12px calc(var(--nav-h) + 16px);
  padding-top: calc(var(--top-h) + 12px);
  min-height: 100vh;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 15px; }
.badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
}

.semaforo {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--verde);
}
.semaforo.ambar { background: var(--ambar); }
.semaforo.rojo { background: var(--rojo); }

.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
}
.bottomnav a.activo { color: var(--accent); font-weight: 700; }

.view { display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card.aviso {
  background: color-mix(in srgb, var(--ambar) 12%, var(--card));
  border-color: var(--ambar);
  font-size: 13px;
  color: var(--text);
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.row-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.row-inline input { width: auto; margin: 0; }
.row > input, .row > select { flex: 1; margin-bottom: 0; }

.btn {
  display: inline-block;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.btn-primario {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
  width: 100%;
}
.btn:disabled { opacity: 0.5; }

.grid-botones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.precio-grande { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.subida { color: var(--verde); }
.bajada { color: var(--rojo); }

.grafico { width: 100%; display: block; }

table.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabla th, table.tabla td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--border); }
table.tabla th { color: var(--muted); font-weight: 600; }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
}
.pill.alcista { background: color-mix(in srgb, var(--verde) 20%, transparent); color: var(--verde); }
.pill.bajista { background: color-mix(in srgb, var(--rojo) 20%, transparent); color: var(--rojo); }
.pill.alta { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }
.pill.media { background: color-mix(in srgb, var(--ambar) 20%, transparent); color: var(--ambar); }
.pill.baja { background: var(--border); color: var(--muted); }

.noticia { padding: 8px 0; border-bottom: 1px solid var(--border); }
.noticia:last-child { border-bottom: none; }
.noticia .fecha { font-size: 11px; color: var(--muted); }
.noticia a { color: var(--accent); text-decoration: none; font-size: 13px; }

.lista-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.lista-item:last-child { border-bottom: none; }
